From 6cd74ee9c79f72f2a19cb2a469077fdaf633332d Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 19 Jun 2022 22:57:10 -0400 Subject: [PATCH] Pass --color=always through cargo-miri --- cargo-miri/bin.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs index 8b11016ca1be0..6a5e5dc3913ab 100644 --- a/cargo-miri/bin.rs +++ b/cargo-miri/bin.rs @@ -945,7 +945,14 @@ fn phase_runner(binary: &Path, binary_args: env::Args, phase: RunnerPhase) { // Drop this argument. } else if let Some(suffix) = arg.strip_prefix(json_flag) { assert!(suffix.starts_with('=')); - // Drop this argument. + // 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 + if arg.split(',').any(|a| a == "diagnostic-rendered-ansi") { + cmd.arg("--color=always"); + } + // But aside from remembering that colored output was requested, drop this argument. } else { cmd.arg(arg); }