Description
Running Servo’s unit tests started failing on CI a couple nightlies ago. A customized CI task to add -j1
shows:
Compiling servo_remutex v0.0.1 (/repo/components/remutex)
Running `sccache rustc --edition=2018 --crate-name smoke components/remutex/tests/smoke.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C debuginfo=2 --test -C metadata=5076d3288909fc2b -C extra-filename=-5076d3288909fc2b --out-dir /repo/target/debug/deps -L dependency=/repo/target/debug/deps --extern lazy_static=/repo/target/debug/deps/liblazy_static-30d72531331b6d3e.rlib --extern log=/repo/target/debug/deps/liblog-147e2d153a2e1822.rlib --extern servo_remutex=/repo/target/debug/deps/libservo_remutex-8b018814b17ada98.rlib -C link-args=-fuse-ld=gold -W unused-extern-crates`
error: cannot specify the `--color` option with `--json`
error: could not compile `servo_remutex`.
The error message appears to come from here:
rust/src/librustc/session/config.rs
Lines 1966 to 1971 in da59656
Reading through the call sites of this function I quickly reach env::args_os()
in rustc_driver::main
, so I don’t understand how this message could be emitted while --color
is not actually present in the command-line arguments given to rustc by Cargo.
I have also not managed to reproduce this outside of the CI environment.
I don’t have an exact regression range, but this started happening a couple days ago which is close to when #65445 landed. This PR updated Cargo, including rust-lang/cargo#7450 whose description mentions using rustc’s JSON output more. I suspect this is what caused the issue to be uncovered, but it looks like the root cause is in rustc’s argument parsing.