@@ -32,7 +32,7 @@ pub use rustc_middle::ty::IntVarValue;
3232use rustc_middle:: ty:: { self , GenericParamDefKind , InferConst , Ty , TyCtxt } ;
3333use rustc_middle:: ty:: { ConstVid , FloatVid , IntVid , TyVid } ;
3434use rustc_span:: symbol:: Symbol ;
35- use rustc_span:: Span ;
35+ use rustc_span:: { Span , DUMMY_SP } ;
3636
3737use std:: cell:: { Cell , Ref , RefCell } ;
3838use std:: fmt;
@@ -316,12 +316,12 @@ pub struct InferCtxt<'a, 'tcx> {
316316 ///
317317 /// Don't read this flag directly, call `is_tainted_by_errors()`
318318 /// and `set_tainted_by_errors()`.
319- tainted_by_errors_flag : Cell < bool > ,
319+ tainted_by_errors : Cell < Option < ErrorGuaranteed > > ,
320320
321321 /// Track how many errors were reported when this infcx is created.
322322 /// If the number of errors increases, that's also a sign (line
323323 /// `tainted_by_errors`) to avoid reporting certain kinds of errors.
324- // FIXME(matthewjasper) Merge into `tainted_by_errors_flag `
324+ // FIXME(matthewjasper) Merge into `tainted_by_errors `
325325 err_count_on_creation : usize ,
326326
327327 /// This flag is true while there is an active snapshot.
@@ -624,7 +624,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
624624 evaluation_cache : Default :: default ( ) ,
625625 reported_trait_errors : Default :: default ( ) ,
626626 reported_closure_mismatch : Default :: default ( ) ,
627- tainted_by_errors_flag : Cell :: new ( false ) ,
627+ tainted_by_errors : Cell :: new ( None ) ,
628628 err_count_on_creation : tcx. sess . err_count ( ) ,
629629 in_snapshot : Cell :: new ( false ) ,
630630 skip_leak_check : Cell :: new ( false ) ,
@@ -1227,23 +1227,25 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12271227 pub fn is_tainted_by_errors ( & self ) -> bool {
12281228 debug ! (
12291229 "is_tainted_by_errors(err_count={}, err_count_on_creation={}, \
1230- tainted_by_errors_flag ={})",
1230+ tainted_by_errors ={})",
12311231 self . tcx. sess. err_count( ) ,
12321232 self . err_count_on_creation,
1233- self . tainted_by_errors_flag . get( )
1233+ self . tainted_by_errors . get( ) . is_some ( )
12341234 ) ;
12351235
12361236 if self . tcx . sess . err_count ( ) > self . err_count_on_creation {
12371237 return true ; // errors reported since this infcx was made
12381238 }
1239- self . tainted_by_errors_flag . get ( )
1239+ self . tainted_by_errors . get ( ) . is_some ( )
12401240 }
12411241
12421242 /// Set the "tainted by errors" flag to true. We call this when we
12431243 /// observe an error from a prior pass.
12441244 pub fn set_tainted_by_errors ( & self ) {
12451245 debug ! ( "set_tainted_by_errors()" ) ;
1246- self . tainted_by_errors_flag . set ( true )
1246+ self . tainted_by_errors . set ( Some (
1247+ self . tcx . sess . delay_span_bug ( DUMMY_SP , "`InferCtxt` incorrectly tainted by errors" ) ,
1248+ ) ) ;
12471249 }
12481250
12491251 pub fn skip_region_resolution ( & self ) {
0 commit comments