@@ -35,6 +35,7 @@ use rustc_target::spec::abi;
3535use rustc_trait_selection:: infer:: InferCtxtExt ;
3636use rustc_trait_selection:: traits:: error_reporting:: suggestions:: NextTypeParamName ;
3737use rustc_trait_selection:: traits:: ObligationCtxt ;
38+ use std:: cell:: Cell ;
3839use std:: iter;
3940use std:: ops:: Bound ;
4041
@@ -119,6 +120,7 @@ pub fn provide(providers: &mut Providers) {
119120pub struct ItemCtxt < ' tcx > {
120121 tcx : TyCtxt < ' tcx > ,
121122 item_def_id : LocalDefId ,
123+ tainted_by_errors : Cell < Option < ErrorGuaranteed > > ,
122124}
123125
124126///////////////////////////////////////////////////////////////////////////
@@ -343,7 +345,7 @@ fn bad_placeholder<'tcx>(
343345
344346impl < ' tcx > ItemCtxt < ' tcx > {
345347 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 ) }
347349 }
348350
349351 pub fn to_ty ( & self , ast_ty : & hir:: Ty < ' _ > ) -> Ty < ' tcx > {
@@ -357,6 +359,13 @@ impl<'tcx> ItemCtxt<'tcx> {
357359 pub fn node ( & self ) -> hir:: Node < ' tcx > {
358360 self . tcx . hir_node ( self . hir_id ( ) )
359361 }
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+ }
360369}
361370
362371impl < ' tcx > AstConv < ' tcx > for ItemCtxt < ' tcx > {
@@ -492,8 +501,8 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
492501 ty. ty_adt_def ( )
493502 }
494503
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 ) ) ;
497506 }
498507
499508 fn record_ty ( & self , _hir_id : hir:: HirId , _ty : Ty < ' tcx > , _span : Span ) {
0 commit comments