diff options
| author | xFrednet <xFrednet@gmail.com> | 2021-11-25 21:59:55 +0100 |
|---|---|---|
| committer | xFrednet <xFrednet@gmail.com> | 2022-03-02 17:46:11 +0100 |
| commit | 4887eb7b2d0e427a0dbf07bfade329101389e32a (patch) | |
| tree | 99a66b235c44ff2245378a0747057033903642e2 /compiler/rustc_errors/src/lib.rs | |
| parent | 3414ad95517933c40d8e66c14b951ee5ede3e0cb (diff) | |
| download | rust-4887eb7b2d0e427a0dbf07bfade329101389e32a.tar.gz rust-4887eb7b2d0e427a0dbf07bfade329101389e32a.zip | |
Added `panics` for unreachable states for expectations (RFC 2383)
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index b53208a6e5d..6dc91a5aa9c 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -942,18 +942,22 @@ impl Handler { let mut inner = self.inner.borrow_mut(); for mut diag in diags.into_iter() { - if let Some(mut unstable_id) = diag.level.get_expectation_id() { - let lint_index = unstable_id.get_lint_index(); - - // The unstable to stable map only maps the unstable it to a stable id - // the lint index is manually transferred here. - unstable_id.set_lint_index(None); - if let Some(mut stable_id) = unstable_to_stable.get(&unstable_id).map(|id| *id) { - stable_id.set_lint_index(lint_index); - diag.level = Level::Expect(stable_id); - inner.fulfilled_expectations.insert(stable_id); - } - } + let mut unstable_id = diag + .level + .get_expectation_id() + .expect("all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`"); + + // The unstable to stable map only maps the unstable it to a stable id + // the lint index is manually transferred here. + let lint_index = unstable_id.get_lint_index(); + unstable_id.set_lint_index(None); + let mut stable_id = *unstable_to_stable + .get(&unstable_id) + .expect("each unstable `LintExpectationId` must have a matching stable id"); + + stable_id.set_lint_index(lint_index); + diag.level = Level::Expect(stable_id); + inner.fulfilled_expectations.insert(stable_id); (*TRACK_DIAGNOSTICS)(&diag); } |
