@@ -2,9 +2,9 @@ use rustc_data_structures::frozen::Frozen;
2
2
use rustc_data_structures:: transitive_relation:: { TransitiveRelation , TransitiveRelationBuilder } ;
3
3
use rustc_hir:: def:: DefKind ;
4
4
use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
5
+ use rustc_infer:: infer:: outlives;
5
6
use rustc_infer:: infer:: outlives:: env:: RegionBoundPairs ;
6
7
use rustc_infer:: infer:: region_constraints:: GenericKind ;
7
- use rustc_infer:: infer:: { InferCtxt , outlives} ;
8
8
use rustc_infer:: traits:: query:: type_op:: DeeplyNormalize ;
9
9
use rustc_middle:: mir:: ConstraintCategory ;
10
10
use rustc_middle:: traits:: query:: OutlivesBound ;
@@ -14,6 +14,7 @@ use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
14
14
use tracing:: { debug, instrument} ;
15
15
use type_op:: TypeOpOutput ;
16
16
17
+ use crate :: BorrowckInferCtxt ;
17
18
use crate :: type_check:: { Locations , MirTypeckRegionConstraints , constraint_conversion} ;
18
19
use crate :: universal_regions:: UniversalRegions ;
19
20
@@ -47,14 +48,12 @@ pub(crate) struct CreateResult<'tcx> {
47
48
}
48
49
49
50
pub ( crate ) fn create < ' tcx > (
50
- infcx : & InferCtxt < ' tcx > ,
51
- param_env : ty:: ParamEnv < ' tcx > ,
51
+ infcx : & BorrowckInferCtxt < ' tcx > ,
52
52
universal_regions : UniversalRegions < ' tcx > ,
53
53
constraints : & mut MirTypeckRegionConstraints < ' tcx > ,
54
54
) -> CreateResult < ' tcx > {
55
55
UniversalRegionRelationsBuilder {
56
56
infcx,
57
- param_env,
58
57
constraints,
59
58
universal_regions,
60
59
region_bound_pairs : Default :: default ( ) ,
@@ -177,8 +176,7 @@ impl UniversalRegionRelations<'_> {
177
176
}
178
177
179
178
struct UniversalRegionRelationsBuilder < ' a , ' tcx > {
180
- infcx : & ' a InferCtxt < ' tcx > ,
181
- param_env : ty:: ParamEnv < ' tcx > ,
179
+ infcx : & ' a BorrowckInferCtxt < ' tcx > ,
182
180
universal_regions : UniversalRegions < ' tcx > ,
183
181
constraints : & ' a mut MirTypeckRegionConstraints < ' tcx > ,
184
182
@@ -205,7 +203,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
205
203
206
204
// Insert the `'a: 'b` we know from the predicates.
207
205
// This does not consider the type-outlives.
208
- let param_env = self . param_env ;
206
+ let param_env = self . infcx . param_env ;
209
207
self . add_outlives_bounds ( outlives:: explicit_outlives_bounds ( param_env) ) ;
210
208
211
209
// - outlives is reflexive, so `'r: 'r` for every region `'r`
@@ -263,7 +261,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
263
261
let TypeOpOutput { output : norm_ty, constraints : constraints_normalize, .. } =
264
262
param_env
265
263
. and ( DeeplyNormalize { value : ty } )
266
- . fully_perform ( self . infcx , span)
264
+ . fully_perform ( self . infcx , self . infcx . root_def_id , span)
267
265
. unwrap_or_else ( |guar| TypeOpOutput {
268
266
output : Ty :: new_error ( self . infcx . tcx , guar) ,
269
267
constraints : None ,
@@ -298,8 +296,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
298
296
// Add implied bounds from impl header.
299
297
if matches ! ( tcx. def_kind( defining_ty_def_id) , DefKind :: AssocFn | DefKind :: AssocConst ) {
300
298
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) ;
303
302
let Ok ( TypeOpOutput { output : norm_ty, constraints : c, .. } ) = result else {
304
303
continue ;
305
304
} ;
@@ -318,7 +317,6 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
318
317
self . infcx ,
319
318
& self . universal_regions ,
320
319
& self . region_bound_pairs ,
321
- param_env,
322
320
& known_type_outlives_obligations,
323
321
Locations :: All ( span) ,
324
322
span,
@@ -353,10 +351,11 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
353
351
output : normalized_outlives,
354
352
constraints : constraints_normalize,
355
353
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
+ )
360
359
else {
361
360
self . infcx . dcx ( ) . delayed_bug ( format ! ( "could not normalize {outlives:?}" ) ) ;
362
361
return ;
@@ -381,9 +380,10 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
381
380
span : Span ,
382
381
) -> Option < & ' tcx QueryRegionConstraints < ' tcx > > {
383
382
let TypeOpOutput { output : bounds, constraints, .. } = self
383
+ . infcx
384
384
. param_env
385
385
. and ( type_op:: ImpliedOutlivesBounds { ty } )
386
- . fully_perform ( self . infcx , span)
386
+ . fully_perform ( self . infcx , self . infcx . root_def_id , span)
387
387
. map_err ( |_: ErrorGuaranteed | debug ! ( "failed to compute implied bounds {:?}" , ty) )
388
388
. ok ( ) ?;
389
389
debug ! ( ?bounds, ?constraints) ;
0 commit comments