File tree 2 files changed +18
-12
lines changed
2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -942,18 +942,22 @@ impl Handler {
942
942
943
943
let mut inner = self . inner . borrow_mut ( ) ;
944
944
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) ;
957
961
958
962
( * TRACK_DIAGNOSTICS ) ( & diag) ;
959
963
}
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ pub fn check_expectations(tcx: TyCtxt<'_>) {
20
20
// holds stable ids
21
21
if let LintExpectationId :: Stable { hir_id, .. } = id {
22
22
emit_unfulfilled_expectation_lint ( tcx, * hir_id, expectation) ;
23
+ } else {
24
+ unreachable ! ( "at this stage all `LintExpectationId`s are stable" ) ;
23
25
}
24
26
}
25
27
}
You can’t perform that action at this time.
0 commit comments