88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- use borrow_check:: nll:: region_infer:: { ConstraintIndex , RegionInferenceContext } ;
11+ use borrow_check:: nll:: constraints:: OutlivesConstraint ;
12+ use borrow_check:: nll:: region_infer:: RegionInferenceContext ;
1213use borrow_check:: nll:: type_check:: Locations ;
1314use rustc:: hir:: def_id:: DefId ;
1415use rustc:: infer:: error_reporting:: nice_region_error:: NiceRegionError ;
@@ -53,7 +54,7 @@ impl fmt::Display for ConstraintCategory {
5354#[ derive( Copy , Clone , PartialEq , Eq ) ]
5455enum Trace {
5556 StartRegion ,
56- FromConstraint ( ConstraintIndex ) ,
57+ FromOutlivesConstraint ( OutlivesConstraint ) ,
5758 NotVisited ,
5859}
5960
@@ -80,12 +81,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
8081 debug ! (
8182 "best_blame_constraint: path={:#?}" ,
8283 path. iter( )
83- . map( |& ci| format!(
84- "{:?}: {:?} ({:?}: {:?})" ,
85- ci,
86- & self . constraints[ ci] ,
87- self . constraint_sccs. scc( self . constraints[ ci] . sup) ,
88- self . constraint_sccs. scc( self . constraints[ ci] . sub) ,
84+ . map( |& c| format!(
85+ "{:?} ({:?}: {:?})" ,
86+ c,
87+ self . constraint_sccs. scc( c. sup) ,
88+ self . constraint_sccs. scc( c. sub) ,
8989 ) )
9090 . collect:: <Vec <_>>( )
9191 ) ;
@@ -121,7 +121,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
121121 // highlight (e.g., a call site or something).
122122 let target_scc = self . constraint_sccs . scc ( target_region) ;
123123 let best_choice = ( 0 ..path. len ( ) ) . rev ( ) . find ( |& i| {
124- let constraint = & self . constraints [ path[ i] ] ;
124+ let constraint = path[ i] ;
125125
126126 let constraint_sup_scc = self . constraint_sccs . scc ( constraint. sup ) ;
127127
@@ -164,7 +164,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
164164 & self ,
165165 from_region : RegionVid ,
166166 target_test : impl Fn ( RegionVid ) -> bool ,
167- ) -> Option < ( Vec < ConstraintIndex > , RegionVid ) > {
167+ ) -> Option < ( Vec < OutlivesConstraint > , RegionVid ) > {
168168 let mut context = IndexVec :: from_elem ( Trace :: NotVisited , & self . definitions ) ;
169169 context[ from_region] = Trace :: StartRegion ;
170170
@@ -185,9 +185,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
185185 Trace :: NotVisited => {
186186 bug ! ( "found unvisited region {:?} on path to {:?}" , p, r)
187187 }
188- Trace :: FromConstraint ( c) => {
188+ Trace :: FromOutlivesConstraint ( c) => {
189189 result. push ( c) ;
190- p = self . constraints [ c ] . sup ;
190+ p = c . sup ;
191191 }
192192
193193 Trace :: StartRegion => {
@@ -201,11 +201,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
201201 // Otherwise, walk over the outgoing constraints and
202202 // enqueue any regions we find, keeping track of how we
203203 // reached them.
204- for constraint in self . constraint_graph . outgoing_edges ( r) {
205- assert_eq ! ( self . constraints [ constraint] . sup, r) ;
206- let sub_region = self . constraints [ constraint] . sub ;
204+ for constraint in self . constraint_graph . outgoing_edges ( r, & self . constraints ) {
205+ assert_eq ! ( constraint. sup, r) ;
206+ let sub_region = constraint. sub ;
207207 if let Trace :: NotVisited = context[ sub_region] {
208- context[ sub_region] = Trace :: FromConstraint ( constraint) ;
208+ context[ sub_region] = Trace :: FromOutlivesConstraint ( constraint) ;
209209 deque. push_back ( sub_region) ;
210210 }
211211 }
@@ -216,8 +216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
216216
217217 /// This function will return true if a constraint is interesting and false if a constraint
218218 /// is not. It is useful in filtering constraint paths to only interesting points.
219- fn constraint_is_interesting ( & self , index : ConstraintIndex ) -> bool {
220- let constraint = self . constraints [ index] ;
219+ fn constraint_is_interesting ( & self , constraint : OutlivesConstraint ) -> bool {
221220 debug ! (
222221 "constraint_is_interesting: locations={:?} constraint={:?}" ,
223222 constraint. locations, constraint
@@ -232,19 +231,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
232231 /// This function classifies a constraint from a location.
233232 fn classify_constraint (
234233 & self ,
235- index : ConstraintIndex ,
234+ constraint : OutlivesConstraint ,
236235 mir : & Mir < ' tcx > ,
237236 tcx : TyCtxt < ' _ , ' _ , ' tcx > ,
238237 ) -> ( ConstraintCategory , Span ) {
239- let constraint = self . constraints [ index] ;
240238 debug ! ( "classify_constraint: constraint={:?}" , constraint) ;
241239 let span = constraint. locations . span ( mir) ;
242240 let location = constraint
243241 . locations
244242 . from_location ( )
245243 . unwrap_or ( Location :: START ) ;
246244
247- if !self . constraint_is_interesting ( index ) {
245+ if !self . constraint_is_interesting ( constraint ) {
248246 return ( ConstraintCategory :: Boring , span) ;
249247 }
250248
0 commit comments