@@ -526,12 +526,15 @@ pub enum StashKey {
526
526
UndeterminedMacroResolution ,
527
527
}
528
528
529
- fn default_track_diagnostic ( diag : DiagInner , f : & mut dyn FnMut ( DiagInner ) ) {
529
+ fn default_track_diagnostic < R > ( diag : DiagInner , f : & mut dyn FnMut ( DiagInner ) -> R ) -> R {
530
530
( * f) ( diag)
531
531
}
532
532
533
- pub static TRACK_DIAGNOSTIC : AtomicRef < fn ( DiagInner , & mut dyn FnMut ( DiagInner ) ) > =
534
- AtomicRef :: new ( & ( default_track_diagnostic as _ ) ) ;
533
+ /// Diagnostics emitted by `DiagCtxtInner::emit_diagnostic` are passed through this function. Used
534
+ /// for tracking by incremental, to replay diagnostics as necessary.
535
+ pub static TRACK_DIAGNOSTIC : AtomicRef <
536
+ fn ( DiagInner , & mut dyn FnMut ( DiagInner ) -> Option < ErrorGuaranteed > ) -> Option < ErrorGuaranteed > ,
537
+ > = AtomicRef :: new ( & ( default_track_diagnostic as _ ) ) ;
535
538
536
539
#[ derive( Copy , Clone , Default ) ]
537
540
pub struct DiagCtxtFlags {
@@ -1406,19 +1409,18 @@ impl DiagCtxtInner {
1406
1409
}
1407
1410
Warning if !self . flags . can_emit_warnings => {
1408
1411
if diagnostic. has_future_breakage ( ) {
1409
- ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1412
+ TRACK_DIAGNOSTIC ( diagnostic, & mut |_| None ) ;
1410
1413
}
1411
1414
return None ;
1412
1415
}
1413
1416
Allow | Expect ( _) => {
1414
- ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1417
+ TRACK_DIAGNOSTIC ( diagnostic, & mut |_| None ) ;
1415
1418
return None ;
1416
1419
}
1417
1420
_ => { }
1418
1421
}
1419
1422
1420
- let mut guaranteed = None ;
1421
- ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |mut diagnostic| {
1423
+ TRACK_DIAGNOSTIC ( diagnostic, & mut |mut diagnostic| {
1422
1424
if let Some ( code) = diagnostic. code {
1423
1425
self . emitted_diagnostic_codes . insert ( code) ;
1424
1426
}
@@ -1481,17 +1483,17 @@ impl DiagCtxtInner {
1481
1483
// `ErrorGuaranteed` for errors and lint errors originates.
1482
1484
#[ allow( deprecated) ]
1483
1485
let guar = ErrorGuaranteed :: unchecked_error_guaranteed ( ) ;
1484
- guaranteed = Some ( guar) ;
1485
1486
if is_lint {
1486
1487
self . lint_err_guars . push ( guar) ;
1487
1488
} else {
1488
1489
self . err_guars . push ( guar) ;
1489
1490
}
1490
1491
self . panic_if_treat_err_as_bug ( ) ;
1492
+ Some ( guar)
1493
+ } else {
1494
+ None
1491
1495
}
1492
- } ) ;
1493
-
1494
- guaranteed
1496
+ } )
1495
1497
}
1496
1498
1497
1499
fn treat_err_as_bug ( & self ) -> bool {
0 commit comments