@@ -35,6 +35,7 @@ use rustc_target::spec::abi;
35
35
use rustc_trait_selection:: infer:: InferCtxtExt ;
36
36
use rustc_trait_selection:: traits:: error_reporting:: suggestions:: NextTypeParamName ;
37
37
use rustc_trait_selection:: traits:: ObligationCtxt ;
38
+ use std:: cell:: Cell ;
38
39
use std:: iter;
39
40
use std:: ops:: Bound ;
40
41
@@ -119,6 +120,7 @@ pub fn provide(providers: &mut Providers) {
119
120
pub struct ItemCtxt < ' tcx > {
120
121
tcx : TyCtxt < ' tcx > ,
121
122
item_def_id : LocalDefId ,
123
+ tainted_by_errors : Cell < Option < ErrorGuaranteed > > ,
122
124
}
123
125
124
126
///////////////////////////////////////////////////////////////////////////
@@ -343,7 +345,7 @@ fn bad_placeholder<'tcx>(
343
345
344
346
impl < ' tcx > ItemCtxt < ' tcx > {
345
347
pub fn new ( tcx : TyCtxt < ' tcx > , item_def_id : LocalDefId ) -> ItemCtxt < ' tcx > {
346
- ItemCtxt { tcx, item_def_id }
348
+ ItemCtxt { tcx, item_def_id, tainted_by_errors : Cell :: new ( None ) }
347
349
}
348
350
349
351
pub fn to_ty ( & self , ast_ty : & hir:: Ty < ' _ > ) -> Ty < ' tcx > {
@@ -357,6 +359,13 @@ impl<'tcx> ItemCtxt<'tcx> {
357
359
pub fn node ( & self ) -> hir:: Node < ' tcx > {
358
360
self . tcx . hir_node ( self . hir_id ( ) )
359
361
}
362
+
363
+ fn check_tainted_by_errors ( & self ) -> Result < ( ) , ErrorGuaranteed > {
364
+ match self . tainted_by_errors . get ( ) {
365
+ Some ( err) => Err ( err) ,
366
+ None => Ok ( ( ) ) ,
367
+ }
368
+ }
360
369
}
361
370
362
371
impl < ' tcx > AstConv < ' tcx > for ItemCtxt < ' tcx > {
@@ -492,8 +501,8 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
492
501
ty. ty_adt_def ( )
493
502
}
494
503
495
- fn set_tainted_by_errors ( & self , _ : ErrorGuaranteed ) {
496
- // There's no obvious place to track this, so just let it go.
504
+ fn set_tainted_by_errors ( & self , err : ErrorGuaranteed ) {
505
+ self . tainted_by_errors . set ( Some ( err ) ) ;
497
506
}
498
507
499
508
fn record_ty ( & self , _hir_id : hir:: HirId , _ty : Ty < ' tcx > , _span : Span ) {
0 commit comments