Skip to content

Commit

Permalink
oops that was embarrassing
Browse files Browse the repository at this point in the history
  • Loading branch information
norepimorphism committed Sep 24, 2023
1 parent f163dd3 commit 01b95d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cargo-miri/src/phases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
}
}
let cargo_cmd = match subcommand {
MiriCommand::Forward(s) => s,
MiriCommand::Forward(ref s) => s,
MiriCommand::Setup => {
if has_build_std {
println!(
Expand Down Expand Up @@ -131,7 +131,7 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
.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(
Expand Down
26 changes: 21 additions & 5 deletions src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -297,6 +312,7 @@ fn parse_comma_list<T: FromStr>(input: &str) -> Result<Vec<T>, T::Err> {
input.split(',').map(str::parse::<T>).collect()
}

/// Extracts the value associated with the `--crate-name` argument from the given command line.
fn parse_crate_name(args: &Vec<String>) -> Option<&str> {
let mut iter = args.iter();
while let Some(e) = iter.next() {
Expand All @@ -310,7 +326,7 @@ fn parse_crate_name(args: &Vec<String>) -> 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
}
Expand Down

0 comments on commit 01b95d8

Please sign in to comment.