@@ -426,6 +426,13 @@ struct HandlerInner {
426
426
427
427
future_breakage_diagnostics : Vec < Diagnostic > ,
428
428
429
+ /// The [`unstable_expect_diagnostics`] should be empty when this struct is
430
+ /// dropped. However, it can have values if the compilation is stopped early
431
+ /// or is only partially executed. To avoid ICEs, like in rust#94953 we only
432
+ /// check if [`unstable_expect_diagnostics`] is empty, if the expectation ids
433
+ /// have been converted.
434
+ check_unstable_expect_diagnostics : bool ,
435
+
429
436
/// Expected [`Diagnostic`]s store a [`LintExpectationId`] as part of
430
437
/// the lint level. [`LintExpectationId`]s created early during the compilation
431
438
/// (before `HirId`s have been defined) are not stable and can therefore not be
@@ -497,10 +504,12 @@ impl Drop for HandlerInner {
497
504
) ;
498
505
}
499
506
500
- assert ! (
501
- self . unstable_expect_diagnostics. is_empty( ) ,
502
- "all diagnostics with unstable expectations should have been converted" ,
503
- ) ;
507
+ if self . check_unstable_expect_diagnostics {
508
+ assert ! (
509
+ self . unstable_expect_diagnostics. is_empty( ) ,
510
+ "all diagnostics with unstable expectations should have been converted" ,
511
+ ) ;
512
+ }
504
513
}
505
514
}
506
515
@@ -574,6 +583,7 @@ impl Handler {
574
583
emitted_diagnostics : Default :: default ( ) ,
575
584
stashed_diagnostics : Default :: default ( ) ,
576
585
future_breakage_diagnostics : Vec :: new ( ) ,
586
+ check_unstable_expect_diagnostics : false ,
577
587
unstable_expect_diagnostics : Vec :: new ( ) ,
578
588
fulfilled_expectations : Default :: default ( ) ,
579
589
} ) ,
@@ -988,12 +998,13 @@ impl Handler {
988
998
& self ,
989
999
unstable_to_stable : & FxHashMap < LintExpectationId , LintExpectationId > ,
990
1000
) {
991
- let diags = std:: mem:: take ( & mut self . inner . borrow_mut ( ) . unstable_expect_diagnostics ) ;
1001
+ let mut inner = self . inner . borrow_mut ( ) ;
1002
+ let diags = std:: mem:: take ( & mut inner. unstable_expect_diagnostics ) ;
1003
+ inner. check_unstable_expect_diagnostics = true ;
992
1004
if diags. is_empty ( ) {
993
1005
return ;
994
1006
}
995
1007
996
- let mut inner = self . inner . borrow_mut ( ) ;
997
1008
for mut diag in diags. into_iter ( ) {
998
1009
diag. update_unstable_expectation_id ( unstable_to_stable) ;
999
1010
0 commit comments