@@ -27,19 +27,6 @@ pub struct OpaqueTypeDecl<'tcx> {
2727 /// The opaque type (`ty::Opaque`) for this declaration.
2828 pub opaque_type : Ty < ' tcx > ,
2929
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-
4330 /// The span of this particular definition of the opaque type. So
4431 /// for example:
4532 ///
@@ -126,7 +113,7 @@ pub trait InferCtxtExt<'tcx> {
126113
127114 fn constrain_opaque_type < FRR : FreeRegionRelations < ' tcx > > (
128115 & self ,
129- def_id : DefId ,
116+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
130117 opaque_defn : & OpaqueTypeDecl < ' tcx > ,
131118 mode : GenerateMemberConstraints ,
132119 free_region_relations : & FRR ,
@@ -137,7 +124,7 @@ pub trait InferCtxtExt<'tcx> {
137124 & self ,
138125 concrete_ty : Ty < ' tcx > ,
139126 opaque_defn : & OpaqueTypeDecl < ' tcx > ,
140- opaque_type_def_id : DefId ,
127+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
141128 first_own_region_index : usize ,
142129 ) ;
143130
@@ -372,7 +359,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
372359
373360 for & ( opaque_type_key, opaque_defn) in opaque_types {
374361 self . constrain_opaque_type (
375- opaque_type_key. def_id ,
362+ opaque_type_key,
376363 & opaque_defn,
377364 GenerateMemberConstraints :: WhenRequired ,
378365 free_region_relations,
@@ -383,11 +370,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
383370 /// See `constrain_opaque_types` for documentation.
384371 fn constrain_opaque_type < FRR : FreeRegionRelations < ' tcx > > (
385372 & self ,
386- def_id : DefId ,
373+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
387374 opaque_defn : & OpaqueTypeDecl < ' tcx > ,
388375 mode : GenerateMemberConstraints ,
389376 free_region_relations : & FRR ,
390377 ) {
378+ let def_id = opaque_type_key. def_id ;
379+
391380 debug ! ( "constrain_opaque_type()" ) ;
392381 debug ! ( "constrain_opaque_type: def_id={:?}" , def_id) ;
393382 debug ! ( "constrain_opaque_type: opaque_defn={:#?}" , opaque_defn) ;
@@ -426,9 +415,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
426415 let bounds = tcx. explicit_item_bounds ( def_id) ;
427416 debug ! ( "constrain_opaque_type: predicates: {:#?}" , bounds) ;
428417 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 ( ) ;
430419 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 ) ;
432421
433422 let required_region_bounds =
434423 required_region_bounds ( tcx, opaque_type, bounds. into_iter ( ) ) ;
@@ -440,7 +429,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
440429 } ) ;
441430 }
442431 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+ ) ;
444438 }
445439 return ;
446440 }
@@ -454,7 +448,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
454448 // second.
455449 let mut least_region = None ;
456450
457- for subst_arg in & opaque_defn . substs [ first_own_region..] {
451+ for subst_arg in & opaque_type_key . substs [ first_own_region..] {
458452 let subst_region = match subst_arg. unpack ( ) {
459453 GenericArgKind :: Lifetime ( r) => r,
460454 GenericArgKind :: Type ( _) | GenericArgKind :: Const ( _) => continue ,
@@ -484,7 +478,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
484478 return self . generate_member_constraint (
485479 concrete_ty,
486480 opaque_defn,
487- def_id ,
481+ opaque_type_key ,
488482 first_own_region,
489483 ) ;
490484 }
@@ -497,7 +491,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
497491
498492 if let GenerateMemberConstraints :: IfNoStaticBound = mode {
499493 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+ ) ;
501500 }
502501 }
503502 concrete_ty. visit_with ( & mut ConstrainOpaqueTypeRegionVisitor {
@@ -517,14 +516,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
517516 & self ,
518517 concrete_ty : Ty < ' tcx > ,
519518 opaque_defn : & OpaqueTypeDecl < ' tcx > ,
520- opaque_type_def_id : DefId ,
519+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
521520 first_own_region : usize ,
522521 ) {
523522 // Create the set of choice regions: each region in the hidden
524523 // type can be equal to any of the region parameters of the
525524 // opaque type definition.
526525 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..]
528527 . iter ( )
529528 . filter_map ( |arg| match arg. unpack ( ) {
530529 GenericArgKind :: Lifetime ( r) => Some ( r) ,
@@ -537,7 +536,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
537536 concrete_ty. visit_with ( & mut ConstrainOpaqueTypeRegionVisitor {
538537 op : |r| {
539538 self . member_constraint (
540- opaque_type_def_id ,
539+ opaque_type_key . def_id ,
541540 opaque_defn. definition_span ,
542541 concrete_ty,
543542 r,
@@ -1087,7 +1086,6 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10871086 OpaqueTypeKey { def_id, substs } ,
10881087 OpaqueTypeDecl {
10891088 opaque_type : ty,
1090- substs,
10911089 definition_span,
10921090 concrete_ty : ty_var,
10931091 has_required_region_bounds : !required_region_bounds. is_empty ( ) ,
0 commit comments