@@ -29,7 +29,8 @@ use rustc_macros::extension;
2929use rustc_middle:: ty:: fold:: TypeFoldable ;
3030use rustc_middle:: ty:: print:: with_no_trimmed_paths;
3131use rustc_middle:: ty:: {
32- self , GenericArgs , GenericArgsRef , InlineConstArgs , InlineConstArgsParts , RegionVid , Ty , TyCtxt ,
32+ self , GenericArgs , GenericArgsRef , InlineConstArgs , InlineConstArgsParts , RegionVid , Ty ,
33+ TyCtxt , TypeVisitableExt ,
3334} ;
3435use rustc_middle:: { bug, span_bug} ;
3536use rustc_span:: symbol:: { kw, sym} ;
@@ -688,7 +689,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
688689 defining_ty : DefiningTy < ' tcx > ,
689690 ) -> ty:: Binder < ' tcx , & ' tcx ty:: List < Ty < ' tcx > > > {
690691 let tcx = self . infcx . tcx ;
691- match defining_ty {
692+
693+ let bound_ty = match defining_ty {
692694 DefiningTy :: Closure ( def_id, args) => {
693695 assert_eq ! ( self . mir_def. to_def_id( ) , def_id) ;
694696 let closure_sig = args. as_closure ( ) . sig ( ) ;
@@ -798,6 +800,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
798800 // "output" (the type of the constant).
799801 assert_eq ! ( self . mir_def. to_def_id( ) , def_id) ;
800802 let ty = tcx. type_of ( self . mir_def ) . instantiate_identity ( ) ;
803+
801804 let ty = indices. fold_to_region_vids ( tcx, ty) ;
802805 ty:: Binder :: dummy ( tcx. mk_type_list ( & [ ty] ) )
803806 }
@@ -807,7 +810,14 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
807810 let ty = args. as_inline_const ( ) . ty ( ) ;
808811 ty:: Binder :: dummy ( tcx. mk_type_list ( & [ ty] ) )
809812 }
813+ } ;
814+
815+ // FIXME(#129952): We probably want a more principled approach here.
816+ if let Err ( terr) = bound_ty. skip_binder ( ) . error_reported ( ) {
817+ self . infcx . set_tainted_by_errors ( terr) ;
810818 }
819+
820+ bound_ty
811821 }
812822}
813823
0 commit comments