11use rustc_data_structures:: frozen:: Frozen ;
22use rustc_data_structures:: transitive_relation:: { TransitiveRelation , TransitiveRelationBuilder } ;
33use rustc_hir:: def:: DefKind ;
4+ use rustc_hir:: def_id:: LocalDefId ;
45use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
56use rustc_infer:: infer:: outlives:: env:: RegionBoundPairs ;
67use rustc_infer:: infer:: region_constraints:: GenericKind ;
@@ -48,12 +49,14 @@ pub(crate) struct CreateResult<'tcx> {
4849
4950pub ( crate ) fn create < ' tcx > (
5051 infcx : & InferCtxt < ' tcx > ,
52+ root_def_id : LocalDefId ,
5153 param_env : ty:: ParamEnv < ' tcx > ,
5254 universal_regions : UniversalRegions < ' tcx > ,
5355 constraints : & mut MirTypeckRegionConstraints < ' tcx > ,
5456) -> CreateResult < ' tcx > {
5557 UniversalRegionRelationsBuilder {
5658 infcx,
59+ root_def_id,
5760 param_env,
5861 constraints,
5962 universal_regions,
@@ -178,6 +181,7 @@ impl UniversalRegionRelations<'_> {
178181
179182struct UniversalRegionRelationsBuilder < ' a , ' tcx > {
180183 infcx : & ' a InferCtxt < ' tcx > ,
184+ root_def_id : LocalDefId ,
181185 param_env : ty:: ParamEnv < ' tcx > ,
182186 universal_regions : UniversalRegions < ' tcx > ,
183187 constraints : & ' a mut MirTypeckRegionConstraints < ' tcx > ,
@@ -263,7 +267,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
263267 let TypeOpOutput { output : norm_ty, constraints : constraints_normalize, .. } =
264268 param_env
265269 . and ( DeeplyNormalize { value : ty } )
266- . fully_perform ( self . infcx , span)
270+ . fully_perform ( self . infcx , self . root_def_id , span)
267271 . unwrap_or_else ( |guar| TypeOpOutput {
268272 output : Ty :: new_error ( self . infcx . tcx , guar) ,
269273 constraints : None ,
@@ -298,8 +302,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
298302 // Add implied bounds from impl header.
299303 if matches ! ( tcx. def_kind( defining_ty_def_id) , DefKind :: AssocFn | DefKind :: AssocConst ) {
300304 for & ( ty, _) in tcx. assumed_wf_types ( tcx. local_parent ( defining_ty_def_id) ) {
301- let result: Result < _ , ErrorGuaranteed > =
302- param_env. and ( DeeplyNormalize { value : ty } ) . fully_perform ( self . infcx , span) ;
305+ let result: Result < _ , ErrorGuaranteed > = param_env
306+ . and ( DeeplyNormalize { value : ty } )
307+ . fully_perform ( self . infcx , self . root_def_id , span) ;
303308 let Ok ( TypeOpOutput { output : norm_ty, constraints : c, .. } ) = result else {
304309 continue ;
305310 } ;
@@ -316,6 +321,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
316321 for c in constraints {
317322 constraint_conversion:: ConstraintConversion :: new (
318323 self . infcx ,
324+ self . root_def_id ,
319325 & self . universal_regions ,
320326 & self . region_bound_pairs ,
321327 param_env,
@@ -353,10 +359,11 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
353359 output : normalized_outlives,
354360 constraints : constraints_normalize,
355361 error_info : _,
356- } ) = self
357- . param_env
358- . and ( DeeplyNormalize { value : outlives } )
359- . fully_perform ( self . infcx , span)
362+ } ) = self . param_env . and ( DeeplyNormalize { value : outlives } ) . fully_perform (
363+ self . infcx ,
364+ self . root_def_id ,
365+ span,
366+ )
360367 else {
361368 self . infcx . dcx ( ) . delayed_bug ( format ! ( "could not normalize {outlives:?}" ) ) ;
362369 return ;
@@ -383,7 +390,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
383390 let TypeOpOutput { output : bounds, constraints, .. } = self
384391 . param_env
385392 . and ( type_op:: ImpliedOutlivesBounds { ty } )
386- . fully_perform ( self . infcx , span)
393+ . fully_perform ( self . infcx , self . root_def_id , span)
387394 . map_err ( |_: ErrorGuaranteed | debug ! ( "failed to compute implied bounds {:?}" , ty) )
388395 . ok ( ) ?;
389396 debug ! ( ?bounds, ?constraints) ;
0 commit comments