File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -942,18 +942,22 @@ impl Handler {
942942
943943 let mut inner = self . inner . borrow_mut ( ) ;
944944 for mut diag in diags. into_iter ( ) {
945- if let Some ( mut unstable_id) = diag. level . get_expectation_id ( ) {
946- let lint_index = unstable_id. get_lint_index ( ) ;
947-
948- // The unstable to stable map only maps the unstable it to a stable id
949- // the lint index is manually transferred here.
950- unstable_id. set_lint_index ( None ) ;
951- if let Some ( mut stable_id) = unstable_to_stable. get ( & unstable_id) . map ( |id| * id) {
952- stable_id. set_lint_index ( lint_index) ;
953- diag. level = Level :: Expect ( stable_id) ;
954- inner. fulfilled_expectations . insert ( stable_id) ;
955- }
956- }
945+ let mut unstable_id = diag
946+ . level
947+ . get_expectation_id ( )
948+ . expect ( "all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`" ) ;
949+
950+ // The unstable to stable map only maps the unstable it to a stable id
951+ // the lint index is manually transferred here.
952+ let lint_index = unstable_id. get_lint_index ( ) ;
953+ unstable_id. set_lint_index ( None ) ;
954+ let mut stable_id = * unstable_to_stable
955+ . get ( & unstable_id)
956+ . expect ( "each unstable `LintExpectationId` must have a matching stable id" ) ;
957+
958+ stable_id. set_lint_index ( lint_index) ;
959+ diag. level = Level :: Expect ( stable_id) ;
960+ inner. fulfilled_expectations . insert ( stable_id) ;
957961
958962 ( * TRACK_DIAGNOSTICS ) ( & diag) ;
959963 }
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ pub fn check_expectations(tcx: TyCtxt<'_>) {
2020 // holds stable ids
2121 if let LintExpectationId :: Stable { hir_id, .. } = id {
2222 emit_unfulfilled_expectation_lint ( tcx, * hir_id, expectation) ;
23+ } else {
24+ unreachable ! ( "at this stage all `LintExpectationId`s are stable" ) ;
2325 }
2426 }
2527 }
You can’t perform that action at this time.
0 commit comments