Skip to content

Commit

Permalink
Give me a way to emit all the delayed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jan 12, 2024
1 parent eb79bc0 commit 7df43d3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ pub struct DiagCtxtFlags {
/// If Some, the Nth error-level diagnostic is upgraded to bug-level.
/// (rustc: see `-Z treat-err-as-bug`)
pub treat_err_as_bug: Option<NonZeroUsize>,
/// Eagerly emit delayed bugs as errors, so that the compiler debugger may
/// see all of the errors being emitted at once.
pub eagerly_emit_delayed_bugs: bool,
/// Show macro backtraces.
/// (rustc: see `-Z macro-backtrace`)
pub macro_backtrace: bool,
Expand Down Expand Up @@ -1274,6 +1277,9 @@ impl DiagCtxtInner {
// when an error is first emitted, also), but maybe there's a case
// in which that's not sound? otherwise this is really inefficient.
match diagnostic.level {
DelayedBug(_) if self.flags.eagerly_emit_delayed_bugs => {
diagnostic.level = Error;
}
DelayedBug(DelayedBugKind::Normal) => {
let backtrace = std::backtrace::Backtrace::capture();
self.span_delayed_bugs
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ impl UnstableOptions {
DiagCtxtFlags {
can_emit_warnings,
treat_err_as_bug: self.treat_err_as_bug,
eagerly_emit_delayed_bugs: self.eagerly_emit_delayed_bugs,
macro_backtrace: self.macro_backtrace,
deduplicate_diagnostics: self.deduplicate_diagnostics,
track_diagnostics: self.track_diagnostics,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,9 @@ options! {
"version of DWARF debug information to emit (default: 2 or 4, depending on platform)"),
dylib_lto: bool = (false, parse_bool, [UNTRACKED],
"enables LTO for dylib crate type"),
eagerly_emit_delayed_bugs: bool = (false, parse_bool, [UNTRACKED],
"emit delayed bugs eagerly as errors instead of stashing them and emitting \
them only if an error has not been emitted"),
ehcont_guard: bool = (false, parse_bool, [TRACKED],
"generate Windows EHCont Guard tables"),
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/treat-err-as-bug/eagerly-emit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// compile-flags: -Zeagerly-emit-delayed-bugs

trait Foo {}

fn main() {}

fn f() -> impl Foo {
//~^ ERROR the trait bound `i32: Foo` is not satisfied
//~| ERROR `report_selection_error` did not emit an error
1i32
}
28 changes: 28 additions & 0 deletions tests/ui/treat-err-as-bug/eagerly-emit.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
error: `report_selection_error` did not emit an error
--> $DIR/eagerly-emit.rs:7:11
|
LL | fn f() -> impl Foo {
| ^^^^^^^^

error: trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging

error[E0277]: the trait bound `i32: Foo` is not satisfied
--> $DIR/eagerly-emit.rs:7:11
|
LL | fn f() -> impl Foo {
| ^^^^^^^^ the trait `Foo` is not implemented for `i32`
...
LL | 1i32
| ---- return type was inferred to be `i32` here
|
help: this trait has no implementations, consider adding one
--> $DIR/eagerly-emit.rs:3:1
|
LL | trait Foo {}
| ^^^^^^^^^

error: expected fulfillment errors

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0277`.

0 comments on commit 7df43d3

Please sign in to comment.