8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use borrow_check:: nll:: region_infer:: { ConstraintIndex , RegionInferenceContext } ;
11
+ use borrow_check:: nll:: constraints:: OutlivesConstraint ;
12
+ use borrow_check:: nll:: region_infer:: RegionInferenceContext ;
12
13
use borrow_check:: nll:: type_check:: Locations ;
13
14
use rustc:: hir:: def_id:: DefId ;
14
15
use rustc:: infer:: error_reporting:: nice_region_error:: NiceRegionError ;
@@ -53,7 +54,7 @@ impl fmt::Display for ConstraintCategory {
53
54
#[ derive( Copy , Clone , PartialEq , Eq ) ]
54
55
enum Trace {
55
56
StartRegion ,
56
- FromConstraint ( ConstraintIndex ) ,
57
+ FromOutlivesConstraint ( OutlivesConstraint ) ,
57
58
NotVisited ,
58
59
}
59
60
@@ -80,12 +81,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
80
81
debug ! (
81
82
"best_blame_constraint: path={:#?}" ,
82
83
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) ,
89
89
) )
90
90
. collect:: <Vec <_>>( )
91
91
) ;
@@ -121,7 +121,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
121
121
// highlight (e.g., a call site or something).
122
122
let target_scc = self . constraint_sccs . scc ( target_region) ;
123
123
let best_choice = ( 0 ..path. len ( ) ) . rev ( ) . find ( |& i| {
124
- let constraint = & self . constraints [ path[ i] ] ;
124
+ let constraint = path[ i] ;
125
125
126
126
let constraint_sup_scc = self . constraint_sccs . scc ( constraint. sup ) ;
127
127
@@ -164,7 +164,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
164
164
& self ,
165
165
from_region : RegionVid ,
166
166
target_test : impl Fn ( RegionVid ) -> bool ,
167
- ) -> Option < ( Vec < ConstraintIndex > , RegionVid ) > {
167
+ ) -> Option < ( Vec < OutlivesConstraint > , RegionVid ) > {
168
168
let mut context = IndexVec :: from_elem ( Trace :: NotVisited , & self . definitions ) ;
169
169
context[ from_region] = Trace :: StartRegion ;
170
170
@@ -185,9 +185,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
185
185
Trace :: NotVisited => {
186
186
bug ! ( "found unvisited region {:?} on path to {:?}" , p, r)
187
187
}
188
- Trace :: FromConstraint ( c) => {
188
+ Trace :: FromOutlivesConstraint ( c) => {
189
189
result. push ( c) ;
190
- p = self . constraints [ c ] . sup ;
190
+ p = c . sup ;
191
191
}
192
192
193
193
Trace :: StartRegion => {
@@ -201,11 +201,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
201
201
// Otherwise, walk over the outgoing constraints and
202
202
// enqueue any regions we find, keeping track of how we
203
203
// 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 ;
207
207
if let Trace :: NotVisited = context[ sub_region] {
208
- context[ sub_region] = Trace :: FromConstraint ( constraint) ;
208
+ context[ sub_region] = Trace :: FromOutlivesConstraint ( constraint) ;
209
209
deque. push_back ( sub_region) ;
210
210
}
211
211
}
@@ -216,8 +216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
216
216
217
217
/// This function will return true if a constraint is interesting and false if a constraint
218
218
/// 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 {
221
220
debug ! (
222
221
"constraint_is_interesting: locations={:?} constraint={:?}" ,
223
222
constraint. locations, constraint
@@ -232,19 +231,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
232
231
/// This function classifies a constraint from a location.
233
232
fn classify_constraint (
234
233
& self ,
235
- index : ConstraintIndex ,
234
+ constraint : OutlivesConstraint ,
236
235
mir : & Mir < ' tcx > ,
237
236
tcx : TyCtxt < ' _ , ' _ , ' tcx > ,
238
237
) -> ( ConstraintCategory , Span ) {
239
- let constraint = self . constraints [ index] ;
240
238
debug ! ( "classify_constraint: constraint={:?}" , constraint) ;
241
239
let span = constraint. locations . span ( mir) ;
242
240
let location = constraint
243
241
. locations
244
242
. from_location ( )
245
243
. unwrap_or ( Location :: START ) ;
246
244
247
- if !self . constraint_is_interesting ( index ) {
245
+ if !self . constraint_is_interesting ( constraint ) {
248
246
return ( ConstraintCategory :: Boring , span) ;
249
247
}
250
248
0 commit comments