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.
This commit is contained in:
Nicholas Nethercote 2024-06-21 13:58:06 +10:00
parent a9c8887c7d
commit d6efcbb760
3 changed files with 28 additions and 6 deletions

View file

@ -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());
}