Skip to content

Commit d5e79f2

Browse files
committed
Include compiler flags when you break rust;
1 parent 9f1de61 commit d5e79f2

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

compiler/rustc_hir_typeck/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,12 @@ fn fatally_break_rust(tcx: TyCtxt<'_>) {
436436
tcx.sess.cfg_version,
437437
config::host_triple(),
438438
));
439+
if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() {
440+
handler.note_without_error(format!("compiler flags: {}", flags.join(" ")));
441+
if excluded_cargo_defaults {
442+
handler.note_without_error("some of the compiler flags provided by cargo are hidden");
443+
}
444+
}
439445
}
440446

441447
fn has_expected_num_generic_args(tcx: TyCtxt<'_>, trait_did: DefId, expected: usize) -> bool {

tests/ui/track-diagnostics/track.rs

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC"
77
// normalize-stderr-test "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET"
88

9+
// The test becomes too flaky if we care about exact args. If `-Z ui-testing`
10+
// from compiletest and `-Z track-diagnostics` from `// compile-flags` at the
11+
// top of this file are present, then assume all args are present.
12+
// normalize-stderr-test "note: compiler flags: .*-Z ui-testing.*-Z track-diagnostics" -> "note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics"
13+
914
fn main() {
1015
break rust
1116
}

tests/ui/track-diagnostics/track.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ note: we would appreciate a joke overview: https://github.com/rust-lang/rust/iss
2020

2121
note: rustc $VERSION running on $TARGET
2222

23+
note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics
24+
2325
error: aborting due to 3 previous errors
2426

2527
Some errors have detailed explanations: E0268, E0425.

0 commit comments

Comments
 (0)