From 01b95d827b4dfa2495577be10d3a437cab2a9376 Mon Sep 17 00:00:00 2001 From: norepimorphism Date: Sat, 23 Sep 2023 21:15:08 -0400 Subject: [PATCH] oops that was embarrassing --- cargo-miri/src/phases.rs | 4 ++-- src/bin/miri.rs | 26 +++++++++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cargo-miri/src/phases.rs b/cargo-miri/src/phases.rs index 32ee299e6a..6e83fe2110 100644 --- a/cargo-miri/src/phases.rs +++ b/cargo-miri/src/phases.rs @@ -103,7 +103,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { } } let cargo_cmd = match subcommand { - MiriCommand::Forward(s) => s, + MiriCommand::Forward(ref s) => s, MiriCommand::Setup => { if has_build_std { println!( @@ -131,7 +131,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator) { .expect("current executable path is not valid UTF-8"); let metadata = get_cargo_metadata(); let mut cmd = cargo(); - cmd.arg(&cargo_cmd); + cmd.arg(cargo_cmd); // In nextest we have to also forward the main `verb`. if cargo_cmd == "nextest" { cmd.arg( diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 19241f4d94..17ef5fee8f 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -243,13 +243,28 @@ fn run_compiler( ) -> ! { if target_crate { if env::var_os("MIRI_STD_AWARE_CARGO").is_some() { - let crate_name = parse_crate_name(&args).unwrap_or_else(|_| { + let crate_name = parse_crate_name(&args).unwrap_or_else(|| { show_error!("`MIRI_STD_AWARE_CARGO` is set but `--crate-name` is not") - }); - if matches!(crate_name, "std" | "core" | "alloc" | "panic_abort" | "test" | "compiler_builtins") { + }) + .to_owned(); + // This list should be kept in sync with the one from + // `cargo/core/compiler/standard_lib.rs`. + if matches!( + crate_name.as_str(), + "std" + | "core" + | "alloc" + | "proc_macro" + | "panic_abort" + | "panic_unwind" + | "test" + | "compiler_builtins" + ) { // We are compiling the standard library. - args.extend(&["-Cdebug-assertions=off", "-Coverflow-checks=on"]); + args.push("-Cdebug-assertions=off".into()); + args.push("-Coverflow-checks=on".into()); } + // See `cargo_miri::phase_rustc`. if crate_name == "panic_abort" { args.push("-Cpanic=abort".into()); } @@ -297,6 +312,7 @@ fn parse_comma_list(input: &str) -> Result, T::Err> { input.split(',').map(str::parse::).collect() } +/// Extracts the value associated with the `--crate-name` argument from the given command line. fn parse_crate_name(args: &Vec) -> Option<&str> { let mut iter = args.iter(); while let Some(e) = iter.next() { @@ -310,7 +326,7 @@ fn parse_crate_name(args: &Vec) -> Option<&str> { show_error!("--crate-name is missing required argument") })); } - show_error!("--crate-name argument is invalid") + show_error!("--crate-name argument is invalid"); } None }