@@ -2,9 +2,9 @@ use rustc_data_structures::frozen::Frozen;
22use rustc_data_structures:: transitive_relation:: { TransitiveRelation , TransitiveRelationBuilder } ;
33use rustc_hir:: def:: DefKind ;
44use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
5+ use rustc_infer:: infer:: outlives;
56use rustc_infer:: infer:: outlives:: env:: RegionBoundPairs ;
67use rustc_infer:: infer:: region_constraints:: GenericKind ;
7- use rustc_infer:: infer:: { InferCtxt , outlives} ;
88use rustc_infer:: traits:: query:: type_op:: DeeplyNormalize ;
99use rustc_middle:: mir:: ConstraintCategory ;
1010use rustc_middle:: traits:: query:: OutlivesBound ;
@@ -14,6 +14,7 @@ use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
1414use tracing:: { debug, instrument} ;
1515use type_op:: TypeOpOutput ;
1616
17+ use crate :: BorrowckInferCtxt ;
1718use crate :: type_check:: { Locations , MirTypeckRegionConstraints , constraint_conversion} ;
1819use crate :: universal_regions:: UniversalRegions ;
1920
@@ -47,14 +48,12 @@ pub(crate) struct CreateResult<'tcx> {
4748}
4849
4950pub ( crate ) fn create < ' tcx > (
50- infcx : & InferCtxt < ' tcx > ,
51- param_env : ty:: ParamEnv < ' tcx > ,
51+ infcx : & BorrowckInferCtxt < ' tcx > ,
5252 universal_regions : UniversalRegions < ' tcx > ,
5353 constraints : & mut MirTypeckRegionConstraints < ' tcx > ,
5454) -> CreateResult < ' tcx > {
5555 UniversalRegionRelationsBuilder {
5656 infcx,
57- param_env,
5857 constraints,
5958 universal_regions,
6059 region_bound_pairs : Default :: default ( ) ,
@@ -177,8 +176,7 @@ impl UniversalRegionRelations<'_> {
177176}
178177
179178struct UniversalRegionRelationsBuilder < ' a , ' tcx > {
180- infcx : & ' a InferCtxt < ' tcx > ,
181- param_env : ty:: ParamEnv < ' tcx > ,
179+ infcx : & ' a BorrowckInferCtxt < ' tcx > ,
182180 universal_regions : UniversalRegions < ' tcx > ,
183181 constraints : & ' a mut MirTypeckRegionConstraints < ' tcx > ,
184182
@@ -205,7 +203,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
205203
206204 // Insert the `'a: 'b` we know from the predicates.
207205 // This does not consider the type-outlives.
208- let param_env = self . param_env ;
206+ let param_env = self . infcx . param_env ;
209207 self . add_outlives_bounds ( outlives:: explicit_outlives_bounds ( param_env) ) ;
210208
211209 // - outlives is reflexive, so `'r: 'r` for every region `'r`
@@ -263,7 +261,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
263261 let TypeOpOutput { output : norm_ty, constraints : constraints_normalize, .. } =
264262 param_env
265263 . and ( DeeplyNormalize { value : ty } )
266- . fully_perform ( self . infcx , span)
264+ . fully_perform ( self . infcx , self . infcx . root_def_id , span)
267265 . unwrap_or_else ( |guar| TypeOpOutput {
268266 output : Ty :: new_error ( self . infcx . tcx , guar) ,
269267 constraints : None ,
@@ -298,8 +296,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
298296 // Add implied bounds from impl header.
299297 if matches ! ( tcx. def_kind( defining_ty_def_id) , DefKind :: AssocFn | DefKind :: AssocConst ) {
300298 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) ;
299+ let result: Result < _ , ErrorGuaranteed > = param_env
300+ . and ( DeeplyNormalize { value : ty } )
301+ . fully_perform ( self . infcx , self . infcx . root_def_id , span) ;
303302 let Ok ( TypeOpOutput { output : norm_ty, constraints : c, .. } ) = result else {
304303 continue ;
305304 } ;
@@ -318,7 +317,6 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
318317 self . infcx ,
319318 & self . universal_regions ,
320319 & self . region_bound_pairs ,
321- param_env,
322320 & known_type_outlives_obligations,
323321 Locations :: All ( span) ,
324322 span,
@@ -353,10 +351,11 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
353351 output : normalized_outlives,
354352 constraints : constraints_normalize,
355353 error_info : _,
356- } ) = self
357- . param_env
358- . and ( DeeplyNormalize { value : outlives } )
359- . fully_perform ( self . infcx , span)
354+ } ) = self . infcx . param_env . and ( DeeplyNormalize { value : outlives } ) . fully_perform (
355+ self . infcx ,
356+ self . infcx . root_def_id ,
357+ span,
358+ )
360359 else {
361360 self . infcx . dcx ( ) . delayed_bug ( format ! ( "could not normalize {outlives:?}" ) ) ;
362361 return ;
@@ -381,9 +380,10 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
381380 span : Span ,
382381 ) -> Option < & ' tcx QueryRegionConstraints < ' tcx > > {
383382 let TypeOpOutput { output : bounds, constraints, .. } = self
383+ . infcx
384384 . param_env
385385 . and ( type_op:: ImpliedOutlivesBounds { ty } )
386- . fully_perform ( self . infcx , span)
386+ . fully_perform ( self . infcx , self . infcx . root_def_id , span)
387387 . map_err ( |_: ErrorGuaranteed | debug ! ( "failed to compute implied bounds {:?}" , ty) )
388388 . ok ( ) ?;
389389 debug ! ( ?bounds, ?constraints) ;
0 commit comments