From da6a78012aa96301b753857bea66e98a34263561 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Mon, 20 Jun 2022 15:16:32 -0400 Subject: [PATCH 1/2] Actually pass through the request for --color=always --- cargo-miri/bin.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs index a7be5843d4e6..6caa96a4f6f6 100644 --- a/cargo-miri/bin.rs +++ b/cargo-miri/bin.rs @@ -957,7 +957,10 @@ fn phase_runner(binary: &Path, binary_args: env::Args, phase: RunnerPhase) { // to emit the diagnostic structure that Cargo would consume from rustc to emit colored // diagnostics, and ask rustc to emit them. // See https://github.com/rust-lang/miri/issues/2037 - if arg.split(',').any(|a| a == "diagnostic-rendered-ansi") { + // First skip over the leading `=`, then check for diagnostic-rendered-ansi in the + // comma-separated list + if suffix.strip_prefix('=').unwrap().split(',').any(|a| a == "diagnostic-rendered-ansi") + { cmd.arg("--color=always"); } // But aside from remembering that colored output was requested, drop this argument. From fed0e1639777cf33caf381ac3bc588ad082398eb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 25 Jun 2022 20:01:36 -0400 Subject: [PATCH 2/2] don't assert the same thing twice --- cargo-miri/bin.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs index 6caa96a4f6f6..4d7b7da6634c 100644 --- a/cargo-miri/bin.rs +++ b/cargo-miri/bin.rs @@ -952,15 +952,14 @@ fn phase_runner(binary: &Path, binary_args: env::Args, phase: RunnerPhase) { assert!(suffix.starts_with('=')); // Drop this argument. } else if let Some(suffix) = arg.strip_prefix(json_flag) { - assert!(suffix.starts_with('=')); + let suffix = suffix.strip_prefix('=').unwrap(); // This is how we pass through --color=always. We detect that Cargo is detecting rustc // to emit the diagnostic structure that Cargo would consume from rustc to emit colored // diagnostics, and ask rustc to emit them. // See https://github.com/rust-lang/miri/issues/2037 // First skip over the leading `=`, then check for diagnostic-rendered-ansi in the // comma-separated list - if suffix.strip_prefix('=').unwrap().split(',').any(|a| a == "diagnostic-rendered-ansi") - { + if suffix.split(',').any(|a| a == "diagnostic-rendered-ansi") { cmd.arg("--color=always"); } // But aside from remembering that colored output was requested, drop this argument.