Skip to content

Commit

Permalink
Include compiler flags when you break rust;
Browse files Browse the repository at this point in the history
  • Loading branch information
Enselic committed Aug 24, 2023
1 parent 9f1de61 commit d5e79f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,12 @@ fn fatally_break_rust(tcx: TyCtxt<'_>) {
tcx.sess.cfg_version,
config::host_triple(),
));
if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() {
handler.note_without_error(format!("compiler flags: {}", flags.join(" ")));
if excluded_cargo_defaults {
handler.note_without_error("some of the compiler flags provided by cargo are hidden");
}
}
}

fn has_expected_num_generic_args(tcx: TyCtxt<'_>, trait_did: DefId, expected: usize) -> bool {
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/track-diagnostics/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC"
// normalize-stderr-test "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET"

// The test becomes too flaky if we care about exact args. If `-Z ui-testing`
// from compiletest and `-Z track-diagnostics` from `// compile-flags` at the
// top of this file are present, then assume all args are present.
// normalize-stderr-test "note: compiler flags: .*-Z ui-testing.*-Z track-diagnostics" -> "note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics"

fn main() {
break rust
}
2 changes: 2 additions & 0 deletions tests/ui/track-diagnostics/track.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ note: we would appreciate a joke overview: https://github.com/rust-lang/rust/iss

note: rustc $VERSION running on $TARGET

note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0268, E0425.
Expand Down

0 comments on commit d5e79f2

Please sign in to comment.