Skip to content

Commit d86736c

Browse files
authored
Rollup merge of #126774 - nnethercote:fix-126751, r=oli-obk
Fix another assertion failure for some Expect diagnostics. Very similar to #126719. So much so that I added a new case to the test from that PR rather than creating a new one. r? `@oli-obk`
2 parents f577d80 + d6efcbb commit d86736c

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

compiler/rustc_errors/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1456,10 +1456,10 @@ impl DiagCtxtInner {
14561456
}
14571457

14581458
if diagnostic.has_future_breakage() {
1459-
// Future breakages aren't emitted if they're `Level::Allow`,
1460-
// but they still need to be constructed and stashed below,
1461-
// so they'll trigger the must_produce_diag check.
1462-
assert!(matches!(diagnostic.level, Error | Warning | Allow));
1459+
// Future breakages aren't emitted if they're `Level::Allow` or
1460+
// `Level::Expect`, but they still need to be constructed and
1461+
// stashed below, so they'll trigger the must_produce_diag check.
1462+
assert!(matches!(diagnostic.level, Error | Warning | Allow | Expect(_)));
14631463
self.future_breakage_diagnostics.push(diagnostic.clone());
14641464
}
14651465

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
// This test covers similar crashes from both #126521 and #126751.
2+
13
macro_rules! foo {
24
($val:ident) => {
35
true;
46
};
57
}
68

9+
macro_rules! bar {
10+
($val:ident) => {
11+
(5_i32.overflowing_sub(3));
12+
};
13+
}
14+
715
fn main() {
816
#[expect(semicolon_in_expressions_from_macros)]
917
//~^ ERROR the `#[expect]` attribute is an experimental feature
1018
let _ = foo!(x);
19+
20+
#[expect(semicolon_in_expressions_from_macros)]
21+
//~^ ERROR the `#[expect]` attribute is an experimental feature
22+
let _ = bar!(x);
1123
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: the `#[expect]` attribute is an experimental feature
2-
--> $DIR/expect-future_breakage-crash-issue-126521.rs:8:5
2+
--> $DIR/expect-future_breakage-crash-issue-126521.rs:16:5
33
|
44
LL | #[expect(semicolon_in_expressions_from_macros)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,6 +8,16 @@ LL | #[expect(semicolon_in_expressions_from_macros)]
88
= help: add `#![feature(lint_reasons)]` to the crate attributes to enable
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

11-
error: aborting due to 1 previous error
11+
error[E0658]: the `#[expect]` attribute is an experimental feature
12+
--> $DIR/expect-future_breakage-crash-issue-126521.rs:20:5
13+
|
14+
LL | #[expect(semicolon_in_expressions_from_macros)]
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
|
17+
= note: see issue #54503 <https://github.com/rust-lang/rust/issues/54503> for more information
18+
= help: add `#![feature(lint_reasons)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error: aborting due to 2 previous errors
1222

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

0 commit comments

Comments
 (0)