Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix another assertion failure for some Expect diagnostics. #126774

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1456,10 +1456,10 @@ impl DiagCtxtInner {
}

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

Expand Down
12 changes: 12 additions & 0 deletions tests/ui/lint/expect-future_breakage-crash-issue-126521.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
// This test covers similar crashes from both #126521 and #126751.

macro_rules! foo {
($val:ident) => {
true;
};
}

macro_rules! bar {
($val:ident) => {
(5_i32.overflowing_sub(3));
};
}

fn main() {
#[expect(semicolon_in_expressions_from_macros)]
//~^ ERROR the `#[expect]` attribute is an experimental feature
let _ = foo!(x);

#[expect(semicolon_in_expressions_from_macros)]
//~^ ERROR the `#[expect]` attribute is an experimental feature
let _ = bar!(x);
}
14 changes: 12 additions & 2 deletions tests/ui/lint/expect-future_breakage-crash-issue-126521.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: the `#[expect]` attribute is an experimental feature
--> $DIR/expect-future_breakage-crash-issue-126521.rs:8:5
--> $DIR/expect-future_breakage-crash-issue-126521.rs:16:5
|
LL | #[expect(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -8,6 +8,16 @@ LL | #[expect(semicolon_in_expressions_from_macros)]
= help: add `#![feature(lint_reasons)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

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

error: aborting due to 2 previous errors

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