@@ -27,19 +27,6 @@ pub struct OpaqueTypeDecl<'tcx> {
27
27
/// The opaque type (`ty::Opaque`) for this declaration.
28
28
pub opaque_type : Ty < ' tcx > ,
29
29
30
- /// The substitutions that we apply to the opaque type that this
31
- /// `impl Trait` desugars to. e.g., if:
32
- ///
33
- /// fn foo<'a, 'b, T>() -> impl Trait<'a>
34
- ///
35
- /// winds up desugared to:
36
- ///
37
- /// type Foo<'x, X> = impl Trait<'x>
38
- /// fn foo<'a, 'b, T>() -> Foo<'a, T>
39
- ///
40
- /// then `substs` would be `['a, T]`.
41
- pub substs : SubstsRef < ' tcx > ,
42
-
43
30
/// The span of this particular definition of the opaque type. So
44
31
/// for example:
45
32
///
@@ -126,7 +113,7 @@ pub trait InferCtxtExt<'tcx> {
126
113
127
114
fn constrain_opaque_type < FRR : FreeRegionRelations < ' tcx > > (
128
115
& self ,
129
- def_id : DefId ,
116
+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
130
117
opaque_defn : & OpaqueTypeDecl < ' tcx > ,
131
118
mode : GenerateMemberConstraints ,
132
119
free_region_relations : & FRR ,
@@ -137,7 +124,7 @@ pub trait InferCtxtExt<'tcx> {
137
124
& self ,
138
125
concrete_ty : Ty < ' tcx > ,
139
126
opaque_defn : & OpaqueTypeDecl < ' tcx > ,
140
- opaque_type_def_id : DefId ,
127
+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
141
128
first_own_region_index : usize ,
142
129
) ;
143
130
@@ -372,7 +359,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
372
359
373
360
for & ( opaque_type_key, opaque_defn) in opaque_types {
374
361
self . constrain_opaque_type (
375
- opaque_type_key. def_id ,
362
+ opaque_type_key,
376
363
& opaque_defn,
377
364
GenerateMemberConstraints :: WhenRequired ,
378
365
free_region_relations,
@@ -383,11 +370,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
383
370
/// See `constrain_opaque_types` for documentation.
384
371
fn constrain_opaque_type < FRR : FreeRegionRelations < ' tcx > > (
385
372
& self ,
386
- def_id : DefId ,
373
+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
387
374
opaque_defn : & OpaqueTypeDecl < ' tcx > ,
388
375
mode : GenerateMemberConstraints ,
389
376
free_region_relations : & FRR ,
390
377
) {
378
+ let def_id = opaque_type_key. def_id ;
379
+
391
380
debug ! ( "constrain_opaque_type()" ) ;
392
381
debug ! ( "constrain_opaque_type: def_id={:?}" , def_id) ;
393
382
debug ! ( "constrain_opaque_type: opaque_defn={:#?}" , opaque_defn) ;
@@ -426,9 +415,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
426
415
let bounds = tcx. explicit_item_bounds ( def_id) ;
427
416
debug ! ( "constrain_opaque_type: predicates: {:#?}" , bounds) ;
428
417
let bounds: Vec < _ > =
429
- bounds. iter ( ) . map ( |( bound, _) | bound. subst ( tcx, opaque_defn . substs ) ) . collect ( ) ;
418
+ bounds. iter ( ) . map ( |( bound, _) | bound. subst ( tcx, opaque_type_key . substs ) ) . collect ( ) ;
430
419
debug ! ( "constrain_opaque_type: bounds={:#?}" , bounds) ;
431
- let opaque_type = tcx. mk_opaque ( def_id, opaque_defn . substs ) ;
420
+ let opaque_type = tcx. mk_opaque ( def_id, opaque_type_key . substs ) ;
432
421
433
422
let required_region_bounds =
434
423
required_region_bounds ( tcx, opaque_type, bounds. into_iter ( ) ) ;
@@ -440,7 +429,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
440
429
} ) ;
441
430
}
442
431
if let GenerateMemberConstraints :: IfNoStaticBound = mode {
443
- self . generate_member_constraint ( concrete_ty, opaque_defn, def_id, first_own_region) ;
432
+ self . generate_member_constraint (
433
+ concrete_ty,
434
+ opaque_defn,
435
+ opaque_type_key,
436
+ first_own_region,
437
+ ) ;
444
438
}
445
439
return ;
446
440
}
@@ -454,7 +448,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
454
448
// second.
455
449
let mut least_region = None ;
456
450
457
- for subst_arg in & opaque_defn . substs [ first_own_region..] {
451
+ for subst_arg in & opaque_type_key . substs [ first_own_region..] {
458
452
let subst_region = match subst_arg. unpack ( ) {
459
453
GenericArgKind :: Lifetime ( r) => r,
460
454
GenericArgKind :: Type ( _) | GenericArgKind :: Const ( _) => continue ,
@@ -484,7 +478,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
484
478
return self . generate_member_constraint (
485
479
concrete_ty,
486
480
opaque_defn,
487
- def_id ,
481
+ opaque_type_key ,
488
482
first_own_region,
489
483
) ;
490
484
}
@@ -497,7 +491,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
497
491
498
492
if let GenerateMemberConstraints :: IfNoStaticBound = mode {
499
493
if least_region != tcx. lifetimes . re_static {
500
- self . generate_member_constraint ( concrete_ty, opaque_defn, def_id, first_own_region) ;
494
+ self . generate_member_constraint (
495
+ concrete_ty,
496
+ opaque_defn,
497
+ opaque_type_key,
498
+ first_own_region,
499
+ ) ;
501
500
}
502
501
}
503
502
concrete_ty. visit_with ( & mut ConstrainOpaqueTypeRegionVisitor {
@@ -517,14 +516,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
517
516
& self ,
518
517
concrete_ty : Ty < ' tcx > ,
519
518
opaque_defn : & OpaqueTypeDecl < ' tcx > ,
520
- opaque_type_def_id : DefId ,
519
+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
521
520
first_own_region : usize ,
522
521
) {
523
522
// Create the set of choice regions: each region in the hidden
524
523
// type can be equal to any of the region parameters of the
525
524
// opaque type definition.
526
525
let choice_regions: Lrc < Vec < ty:: Region < ' tcx > > > = Lrc :: new (
527
- opaque_defn . substs [ first_own_region..]
526
+ opaque_type_key . substs [ first_own_region..]
528
527
. iter ( )
529
528
. filter_map ( |arg| match arg. unpack ( ) {
530
529
GenericArgKind :: Lifetime ( r) => Some ( r) ,
@@ -537,7 +536,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
537
536
concrete_ty. visit_with ( & mut ConstrainOpaqueTypeRegionVisitor {
538
537
op : |r| {
539
538
self . member_constraint (
540
- opaque_type_def_id ,
539
+ opaque_type_key . def_id ,
541
540
opaque_defn. definition_span ,
542
541
concrete_ty,
543
542
r,
@@ -1087,7 +1086,6 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
1087
1086
OpaqueTypeKey { def_id, substs } ,
1088
1087
OpaqueTypeDecl {
1089
1088
opaque_type : ty,
1090
- substs,
1091
1089
definition_span,
1092
1090
concrete_ty : ty_var,
1093
1091
has_required_region_bounds : !required_region_bounds. is_empty ( ) ,
0 commit comments