1
1
use rustc_data_structures:: frozen:: Frozen ;
2
2
use rustc_data_structures:: transitive_relation:: { TransitiveRelation , TransitiveRelationBuilder } ;
3
3
use rustc_hir:: def:: DefKind ;
4
+ use rustc_hir:: def_id:: LocalDefId ;
4
5
use rustc_infer:: infer:: canonical:: QueryRegionConstraints ;
5
6
use rustc_infer:: infer:: outlives:: env:: RegionBoundPairs ;
6
7
use rustc_infer:: infer:: region_constraints:: GenericKind ;
@@ -48,12 +49,14 @@ pub(crate) struct CreateResult<'tcx> {
48
49
49
50
pub ( crate ) fn create < ' tcx > (
50
51
infcx : & InferCtxt < ' tcx > ,
52
+ root_def_id : LocalDefId ,
51
53
param_env : ty:: ParamEnv < ' tcx > ,
52
54
universal_regions : UniversalRegions < ' tcx > ,
53
55
constraints : & mut MirTypeckRegionConstraints < ' tcx > ,
54
56
) -> CreateResult < ' tcx > {
55
57
UniversalRegionRelationsBuilder {
56
58
infcx,
59
+ root_def_id,
57
60
param_env,
58
61
constraints,
59
62
universal_regions,
@@ -178,6 +181,7 @@ impl UniversalRegionRelations<'_> {
178
181
179
182
struct UniversalRegionRelationsBuilder < ' a , ' tcx > {
180
183
infcx : & ' a InferCtxt < ' tcx > ,
184
+ root_def_id : LocalDefId ,
181
185
param_env : ty:: ParamEnv < ' tcx > ,
182
186
universal_regions : UniversalRegions < ' tcx > ,
183
187
constraints : & ' a mut MirTypeckRegionConstraints < ' tcx > ,
@@ -263,7 +267,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
263
267
let TypeOpOutput { output : norm_ty, constraints : constraints_normalize, .. } =
264
268
param_env
265
269
. and ( DeeplyNormalize { value : ty } )
266
- . fully_perform ( self . infcx , span)
270
+ . fully_perform ( self . infcx , self . root_def_id , span)
267
271
. unwrap_or_else ( |guar| TypeOpOutput {
268
272
output : Ty :: new_error ( self . infcx . tcx , guar) ,
269
273
constraints : None ,
@@ -298,8 +302,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
298
302
// Add implied bounds from impl header.
299
303
if matches ! ( tcx. def_kind( defining_ty_def_id) , DefKind :: AssocFn | DefKind :: AssocConst ) {
300
304
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) ;
303
308
let Ok ( TypeOpOutput { output : norm_ty, constraints : c, .. } ) = result else {
304
309
continue ;
305
310
} ;
@@ -316,6 +321,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
316
321
for c in constraints {
317
322
constraint_conversion:: ConstraintConversion :: new (
318
323
self . infcx ,
324
+ self . root_def_id ,
319
325
& self . universal_regions ,
320
326
& self . region_bound_pairs ,
321
327
param_env,
@@ -353,10 +359,11 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
353
359
output : normalized_outlives,
354
360
constraints : constraints_normalize,
355
361
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
+ )
360
367
else {
361
368
self . infcx . dcx ( ) . delayed_bug ( format ! ( "could not normalize {outlives:?}" ) ) ;
362
369
return ;
@@ -383,7 +390,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
383
390
let TypeOpOutput { output : bounds, constraints, .. } = self
384
391
. param_env
385
392
. and ( type_op:: ImpliedOutlivesBounds { ty } )
386
- . fully_perform ( self . infcx , span)
393
+ . fully_perform ( self . infcx , self . root_def_id , span)
387
394
. map_err ( |_: ErrorGuaranteed | debug ! ( "failed to compute implied bounds {:?}" , ty) )
388
395
. ok ( ) ?;
389
396
debug ! ( ?bounds, ?constraints) ;
0 commit comments