-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't consider delayed bugs for
-Ztreat-err-as-bug
.
`-Ztreat-err-as-bug` treats normal errors and delayed bugs equally, which can lead to some really surprising results. This commit changes `-Ztreat-err-as-bug` so it ignores delayed bugs, unless they get promoted to proper bugs and are printed. This feels to me much simpler and more logical. And it simplifies the implementation: - The `-Ztreat-err-as-bug` check is removed from in `DiagCtxt::{delayed_bug,span_delayed_bug}`. - `treat_err_as_bug` doesn't need to count delayed bugs. - The `-Ztreat-err-as-bug` panic message is simpler, because it doesn't have to mention delayed bugs. Output of delayed bugs is now more consistent. They're always printed the same way. Previously when they triggered `-Ztreat-err-as-bug` they would be printed slightly differently, via `span_bug` in `span_delayed_bug` or `delayed_bug`. A minor behaviour change: the "no errors encountered even though `span_delayed_bug` issued" printed before delayed bugs is now a note rather than a bug. This is done so it doesn't get counted as an error that might trigger `-Ztreat-err-as-bug`, which would be silly. This means that if you use `-Ztreat-err-as-bug=1` and there are no normal errors but there are delayed bugs, the first delayed bug will be shown (and the panic will happen after it's printed). Also, I have added a second note saying "those delayed bugs will now be shown as internal compiler errors". I think this makes it clearer what is happening, because the whole concept of delayed bugs is non-obvious. There are some test changes. - equality-in-canonical-query.rs: Minor output changes, and the error count reduces by one because the "no errors encountered even though `span_delayed_bug` issued" message is no longer counted as an error. - rpit_tait_equality_in_canonical_query.rs: Ditto. - tests/ui/mir/lint/*.rs: These tests involved delayed bugs that get shown. The query stack disappears because these delayed bugs are now printed at the end, rather than when they are created. - storage-return.rs: This is the only test with a big change. It triggers a delayed bug and then a normal error. It used to use `-Ztreat-err-as-bug=1` to abort on the delayed bug. That is no longer possible, and the delayed bug doesn't show up because of the normal error. So I changed the test to use the normal error. The normal error does seem related to the delayed bug, so hopefully it's good enough.
- Loading branch information
1 parent
3330940
commit 0bfd2f9
Showing
10 changed files
with
73 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 6 additions & 10 deletions
16
tests/ui/impl-trait/equality-in-canonical-query.clone.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
error: internal compiler error: no errors encountered even though `span_delayed_bug` issued | ||
note: no errors encountered even though `span_delayed_bug` issued | ||
|
||
note: those delayed bugs will now be shown as internal compiler errors | ||
|
||
error: internal compiler error: {OpaqueTypeKey { def_id: DefId(rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }) } }} | ||
| | ||
= | ||
|
||
|
||
error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }))), bound_vars: [] } } } | ||
--> $DIR/equality-in-canonical-query.rs:19:5 | ||
--> $DIR/equality-in-canonical-query.rs:21:5 | ||
| | ||
LL | same_output(foo, rpit); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
|
||
--> $DIR/equality-in-canonical-query.rs:19:5 | ||
--> $DIR/equality-in-canonical-query.rs:21:5 | ||
| | ||
LL | same_output(foo, rpit); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
query stack during panic: | ||
end of query stack | ||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0381]: used binding isn't initialized | ||
--> $DIR/storage-return.rs:11:13 | ||
| | ||
LL | / mir!( | ||
LL | | let a: (); | ||
LL | | { | ||
LL | | StorageLive(a); | ||
LL | | RET = a; | ||
| | ^^^^^^^ value used here but it isn't initialized | ||
LL | | Return() | ||
LL | | } | ||
LL | | ) | ||
| |_____- binding declared here but left uninitialized | ||
| | ||
help: consider assigning a value | ||
| | ||
LL | let a: () = todo!(); | ||
| +++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0381`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
error: internal compiler error: delayed span bug triggered by #[rustc_error(span_delayed_bug_from_inside_query)] | ||
--> $DIR/span_delayed_bug.rs:12:1 | ||
| | ||
LL | fn main() {} | ||
| ^^^^^^^^^ | ||
| | ||
note: delayed at compiler/rustc_middle/src/util/bug.rs:45:15 - disabled backtrace | ||
--> $DIR/span_delayed_bug.rs:12:1 | ||
| | ||
LL | fn main() {} | ||
| ^^^^^^^^^ | ||
|
||
error: the compiler unexpectedly panicked. this is a bug. | ||
|
||
query stack during panic: | ||
#0 [trigger_span_delayed_bug] triggering a span delayed bug for testing incremental | ||
end of query stack |
16 changes: 6 additions & 10 deletions
16
tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
error: internal compiler error: no errors encountered even though `span_delayed_bug` issued | ||
note: no errors encountered even though `span_delayed_bug` issued | ||
|
||
note: those delayed bugs will now be shown as internal compiler errors | ||
|
||
error: internal compiler error: {OpaqueTypeKey { def_id: DefId(get_rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }) } }} | ||
| | ||
= | ||
|
||
|
||
error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(get_rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }))), bound_vars: [] } } } | ||
--> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5 | ||
--> $DIR/rpit_tait_equality_in_canonical_query.rs:31:5 | ||
| | ||
LL | query(get_rpit); | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
|
||
--> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5 | ||
--> $DIR/rpit_tait_equality_in_canonical_query.rs:31:5 | ||
| | ||
LL | query(get_rpit); | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
query stack during panic: | ||
end of query stack | ||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters