@@ -32,7 +32,7 @@ pub use rustc_middle::ty::IntVarValue;
32
32
use rustc_middle:: ty:: { self , GenericParamDefKind , InferConst , Ty , TyCtxt } ;
33
33
use rustc_middle:: ty:: { ConstVid , FloatVid , IntVid , TyVid } ;
34
34
use rustc_span:: symbol:: Symbol ;
35
- use rustc_span:: Span ;
35
+ use rustc_span:: { Span , DUMMY_SP } ;
36
36
37
37
use std:: cell:: { Cell , Ref , RefCell } ;
38
38
use std:: fmt;
@@ -316,12 +316,12 @@ pub struct InferCtxt<'a, 'tcx> {
316
316
///
317
317
/// Don't read this flag directly, call `is_tainted_by_errors()`
318
318
/// and `set_tainted_by_errors()`.
319
- tainted_by_errors_flag : Cell < bool > ,
319
+ tainted_by_errors : Cell < Option < ErrorGuaranteed > > ,
320
320
321
321
/// Track how many errors were reported when this infcx is created.
322
322
/// If the number of errors increases, that's also a sign (line
323
323
/// `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 `
325
325
err_count_on_creation : usize ,
326
326
327
327
/// This flag is true while there is an active snapshot.
@@ -624,7 +624,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
624
624
evaluation_cache : Default :: default ( ) ,
625
625
reported_trait_errors : Default :: default ( ) ,
626
626
reported_closure_mismatch : Default :: default ( ) ,
627
- tainted_by_errors_flag : Cell :: new ( false ) ,
627
+ tainted_by_errors : Cell :: new ( None ) ,
628
628
err_count_on_creation : tcx. sess . err_count ( ) ,
629
629
in_snapshot : Cell :: new ( false ) ,
630
630
skip_leak_check : Cell :: new ( false ) ,
@@ -1227,23 +1227,25 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1227
1227
pub fn is_tainted_by_errors ( & self ) -> bool {
1228
1228
debug ! (
1229
1229
"is_tainted_by_errors(err_count={}, err_count_on_creation={}, \
1230
- tainted_by_errors_flag ={})",
1230
+ tainted_by_errors ={})",
1231
1231
self . tcx. sess. err_count( ) ,
1232
1232
self . err_count_on_creation,
1233
- self . tainted_by_errors_flag . get( )
1233
+ self . tainted_by_errors . get( ) . is_some ( )
1234
1234
) ;
1235
1235
1236
1236
if self . tcx . sess . err_count ( ) > self . err_count_on_creation {
1237
1237
return true ; // errors reported since this infcx was made
1238
1238
}
1239
- self . tainted_by_errors_flag . get ( )
1239
+ self . tainted_by_errors . get ( ) . is_some ( )
1240
1240
}
1241
1241
1242
1242
/// Set the "tainted by errors" flag to true. We call this when we
1243
1243
/// observe an error from a prior pass.
1244
1244
pub fn set_tainted_by_errors ( & self ) {
1245
1245
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
+ ) ) ;
1247
1249
}
1248
1250
1249
1251
pub fn skip_region_resolution ( & self ) {
0 commit comments