Skip to content

Commit 2aac288

Browse files
committed
Use the right level with -Ztreat-err-as-bug.
Errors in `DiagCtxtInner::emit_diagnostic` are never set to `Level::Bug`, because the condition never succeeds, because `self.treat_err_as_bug()` is called *before* the error counts are incremented. This commit switches to `self.treat_next_err_as_bug()`, fixing the problem. This changes the error message output to actually say "internal compiler error".
1 parent f0a3684 commit 2aac288

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ impl DiagCtxtInner {
12561256
}
12571257

12581258
fn emit_diagnostic(&mut self, mut diagnostic: Diagnostic) -> Option<ErrorGuaranteed> {
1259-
if matches!(diagnostic.level, Error | Fatal) && self.treat_err_as_bug() {
1259+
if matches!(diagnostic.level, Error | Fatal) && self.treat_next_err_as_bug() {
12601260
diagnostic.level = Bug;
12611261
}
12621262

tests/rustdoc-ui/ice-bug-report-url.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `->`, `where`, or `{`, found `<eof>`
1+
error: internal compiler error: expected one of `->`, `where`, or `{`, found `<eof>`
22
--> $DIR/ice-bug-report-url.rs:14:10
33
|
44
LL | fn wrong()

tests/ui/consts/const-eval/const-eval-query-stack.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0080]: evaluation of constant value failed
1+
error: internal compiler error[E0080]: evaluation of constant value failed
22
--> $DIR/const-eval-query-stack.rs:16:16
33
|
44
LL | const X: i32 = 1 / 0;

tests/ui/impl-trait/issues/issue-86800.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unconstrained opaque type
44
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
error[E0792]: expected generic lifetime parameter, found `'_`
7+
error: internal compiler error[E0792]: expected generic lifetime parameter, found `'_`
88
--> $DIR/issue-86800.rs:39:5
99
|
1010
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;

tests/ui/panics/default-backtrace-ice.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0425]: cannot find value `missing_ident` in this scope
1+
error: internal compiler error[E0425]: cannot find value `missing_ident` in this scope
22
--> $DIR/default-backtrace-ice.rs:21:13
33
|
44
LL | fn main() { missing_ident; }

tests/ui/treat-err-as-bug/err.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0080]: could not evaluate static initializer
1+
error: internal compiler error[E0080]: could not evaluate static initializer
22
--> $DIR/err.rs:11:21
33
|
44
LL | pub static C: u32 = 0 - 1;

0 commit comments

Comments
 (0)