@@ -4,10 +4,9 @@ use std::ops::Index;
44use rustc_data_structures:: captures:: Captures ;
55use rustc_data_structures:: fx:: FxIndexMap ;
66use rustc_index:: { IndexSlice , IndexVec } ;
7- use rustc_middle:: infer:: MemberConstraint ;
87use rustc_middle:: ty:: { self , Ty } ;
98use rustc_span:: Span ;
10- use tracing:: debug ;
9+ use tracing:: instrument ;
1110
1211/// Compactly stores a set of `R0 member of [R1...Rn]` constraints,
1312/// indexed by the region `R0`.
2322 /// Stores the data about each `R0 member of [R1..Rn]` constraint.
2423 /// These are organized into a linked list, so each constraint
2524 /// contains the index of the next constraint with the same `R0`.
26- constraints : IndexVec < NllMemberConstraintIndex , NllMemberConstraint < ' tcx > > ,
25+ constraints : IndexVec < NllMemberConstraintIndex , MemberConstraint < ' tcx > > ,
2726
2827 /// Stores the `R1..Rn` regions for *all* sets. For any given
2928 /// constraint, we keep two indices so that we can pull out a
3332
3433/// Represents a `R0 member of [R1..Rn]` constraint
3534#[ derive( Debug ) ]
36- pub ( crate ) struct NllMemberConstraint < ' tcx > {
35+ pub ( crate ) struct MemberConstraint < ' tcx > {
3736 next_constraint : Option < NllMemberConstraintIndex > ,
3837
3938 /// The span where the hidden type was instantiated.
@@ -71,36 +70,29 @@ impl Default for MemberConstraintSet<'_, ty::RegionVid> {
7170
7271impl < ' tcx > MemberConstraintSet < ' tcx , ty:: RegionVid > {
7372 /// Pushes a member constraint into the set.
74- ///
75- /// The input member constraint `m_c` is in the form produced by
76- /// the `rustc_middle::infer` code.
77- ///
78- /// The `to_region_vid` callback fn is used to convert the regions
79- /// within into `RegionVid` format -- it typically consults the
80- /// `UniversalRegions` data structure that is known to the caller
81- /// (but which this code is unaware of).
82- pub ( crate ) fn push_constraint (
73+ #[ instrument( level = "debug" , skip( self ) ) ]
74+ pub ( crate ) fn add_member_constraint (
8375 & mut self ,
84- m_c : & MemberConstraint < ' tcx > ,
85- mut to_region_vid : impl FnMut ( ty:: Region < ' tcx > ) -> ty:: RegionVid ,
76+ key : ty:: OpaqueTypeKey < ' tcx > ,
77+ hidden_ty : Ty < ' tcx > ,
78+ definition_span : Span ,
79+ member_region_vid : ty:: RegionVid ,
80+ choice_regions : & [ ty:: RegionVid ] ,
8681 ) {
87- debug ! ( "push_constraint(m_c={:?})" , m_c) ;
88- let member_region_vid: ty:: RegionVid = to_region_vid ( m_c. member_region ) ;
8982 let next_constraint = self . first_constraints . get ( & member_region_vid) . cloned ( ) ;
9083 let start_index = self . choice_regions . len ( ) ;
91- let end_index = start_index + m_c . choice_regions . len ( ) ;
92- debug ! ( "push_constraint: member_region_vid={:?}" , member_region_vid ) ;
93- let constraint_index = self . constraints . push ( NllMemberConstraint {
84+ self . choice_regions . extend ( choice_regions ) ;
85+ let end_index = self . choice_regions . len ( ) ;
86+ let constraint_index = self . constraints . push ( MemberConstraint {
9487 next_constraint,
9588 member_region_vid,
96- definition_span : m_c . definition_span ,
97- hidden_ty : m_c . hidden_ty ,
98- key : m_c . key ,
89+ definition_span,
90+ hidden_ty,
91+ key,
9992 start_index,
10093 end_index,
10194 } ) ;
10295 self . first_constraints . insert ( member_region_vid, constraint_index) ;
103- self . choice_regions . extend ( m_c. choice_regions . iter ( ) . map ( |& r| to_region_vid ( r) ) ) ;
10496 }
10597}
10698
@@ -182,7 +174,7 @@ where
182174 /// R0 member of [R1..Rn]
183175 /// ```
184176 pub ( crate ) fn choice_regions ( & self , pci : NllMemberConstraintIndex ) -> & [ ty:: RegionVid ] {
185- let NllMemberConstraint { start_index, end_index, .. } = & self . constraints [ pci] ;
177+ let MemberConstraint { start_index, end_index, .. } = & self . constraints [ pci] ;
186178 & self . choice_regions [ * start_index..* end_index]
187179 }
188180}
@@ -191,9 +183,9 @@ impl<'tcx, R> Index<NllMemberConstraintIndex> for MemberConstraintSet<'tcx, R>
191183where
192184 R : Copy + Eq ,
193185{
194- type Output = NllMemberConstraint < ' tcx > ;
186+ type Output = MemberConstraint < ' tcx > ;
195187
196- fn index ( & self , i : NllMemberConstraintIndex ) -> & NllMemberConstraint < ' tcx > {
188+ fn index ( & self , i : NllMemberConstraintIndex ) -> & MemberConstraint < ' tcx > {
197189 & self . constraints [ i]
198190 }
199191}
@@ -215,7 +207,7 @@ where
215207/// target_list: A -> B -> C -> D -> E -> F -> (None)
216208/// ```
217209fn append_list (
218- constraints : & mut IndexSlice < NllMemberConstraintIndex , NllMemberConstraint < ' _ > > ,
210+ constraints : & mut IndexSlice < NllMemberConstraintIndex , MemberConstraint < ' _ > > ,
219211 target_list : NllMemberConstraintIndex ,
220212 source_list : NllMemberConstraintIndex ,
221213) {
0 commit comments