Skip to content

Commit 7df43d3

Browse files
Give me a way to emit all the delayed bugs
1 parent eb79bc0 commit 7df43d3

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

compiler/rustc_errors/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ pub struct DiagCtxtFlags {
533533
/// If Some, the Nth error-level diagnostic is upgraded to bug-level.
534534
/// (rustc: see `-Z treat-err-as-bug`)
535535
pub treat_err_as_bug: Option<NonZeroUsize>,
536+
/// Eagerly emit delayed bugs as errors, so that the compiler debugger may
537+
/// see all of the errors being emitted at once.
538+
pub eagerly_emit_delayed_bugs: bool,
536539
/// Show macro backtraces.
537540
/// (rustc: see `-Z macro-backtrace`)
538541
pub macro_backtrace: bool,
@@ -1274,6 +1277,9 @@ impl DiagCtxtInner {
12741277
// when an error is first emitted, also), but maybe there's a case
12751278
// in which that's not sound? otherwise this is really inefficient.
12761279
match diagnostic.level {
1280+
DelayedBug(_) if self.flags.eagerly_emit_delayed_bugs => {
1281+
diagnostic.level = Error;
1282+
}
12771283
DelayedBug(DelayedBugKind::Normal) => {
12781284
let backtrace = std::backtrace::Backtrace::capture();
12791285
self.span_delayed_bugs

compiler/rustc_session/src/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,7 @@ impl UnstableOptions {
11461146
DiagCtxtFlags {
11471147
can_emit_warnings,
11481148
treat_err_as_bug: self.treat_err_as_bug,
1149+
eagerly_emit_delayed_bugs: self.eagerly_emit_delayed_bugs,
11491150
macro_backtrace: self.macro_backtrace,
11501151
deduplicate_diagnostics: self.deduplicate_diagnostics,
11511152
track_diagnostics: self.track_diagnostics,

compiler/rustc_session/src/options.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,9 @@ options! {
15831583
"version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
15841584
dylib_lto: bool = (false, parse_bool, [UNTRACKED],
15851585
"enables LTO for dylib crate type"),
1586+
eagerly_emit_delayed_bugs: bool = (false, parse_bool, [UNTRACKED],
1587+
"emit delayed bugs eagerly as errors instead of stashing them and emitting \
1588+
them only if an error has not been emitted"),
15861589
ehcont_guard: bool = (false, parse_bool, [TRACKED],
15871590
"generate Windows EHCont Guard tables"),
15881591
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// compile-flags: -Zeagerly-emit-delayed-bugs
2+
3+
trait Foo {}
4+
5+
fn main() {}
6+
7+
fn f() -> impl Foo {
8+
//~^ ERROR the trait bound `i32: Foo` is not satisfied
9+
//~| ERROR `report_selection_error` did not emit an error
10+
1i32
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error: `report_selection_error` did not emit an error
2+
--> $DIR/eagerly-emit.rs:7:11
3+
|
4+
LL | fn f() -> impl Foo {
5+
| ^^^^^^^^
6+
7+
error: trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging
8+
9+
error[E0277]: the trait bound `i32: Foo` is not satisfied
10+
--> $DIR/eagerly-emit.rs:7:11
11+
|
12+
LL | fn f() -> impl Foo {
13+
| ^^^^^^^^ the trait `Foo` is not implemented for `i32`
14+
...
15+
LL | 1i32
16+
| ---- return type was inferred to be `i32` here
17+
|
18+
help: this trait has no implementations, consider adding one
19+
--> $DIR/eagerly-emit.rs:3:1
20+
|
21+
LL | trait Foo {}
22+
| ^^^^^^^^^
23+
24+
error: expected fulfillment errors
25+
26+
error: aborting due to 4 previous errors
27+
28+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)