message: cargo-miri: support running unit tests for libraries as well as test binaries
diff: @@ -97,7 +97,8 @@ fn main() {
  let kind = target.kind.get(0).expect(
  "badly formatted cargo metadata: target::kind is an empty array",
  );
  - if test && kind == "test" {
  + match (test, &kind[..]) {
  + (true, "test") => {
  if let Err(code) = process(
  vec!["--test".to_string(), target.name].into_iter().chain(
  args,
  @@ -106,7 +107,18 @@ fn main() {
  {
  std::process::exit(code);
  }
  - } else if !test && kind == "bin" {
  + }
  + (true, "lib") => {
  + if let Err(code) = process(
  + vec!["--".to_string(), "--test".to_string()].into_iter().chain(
  + args,
  + ),
  + )
  + {
  + std::process::exit(code);
  + }
  + }
  + (false, "bin") => {
  if let Err(code) = process(
  vec!["--bin".to_string(), target.name].into_iter().chain(
  args,
  @@ -116,6 +128,8 @@ fn main() {
  std::process::exit(code);
  }
  }
  + _ => {}
  + }
  }
  } else {
  // this arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself
  