3
3
use crate :: hir:: def_id:: DefId ;
4
4
use crate :: infer:: region_constraints:: Constraint ;
5
5
use crate :: infer:: region_constraints:: GenericKind ;
6
- use crate :: infer:: region_constraints:: PickConstraint ;
6
+ use crate :: infer:: region_constraints:: MemberConstraint ;
7
7
use crate :: infer:: region_constraints:: RegionConstraintData ;
8
8
use crate :: infer:: region_constraints:: VarInfos ;
9
9
use crate :: infer:: region_constraints:: VerifyBound ;
@@ -84,15 +84,15 @@ pub enum RegionResolutionError<'tcx> {
84
84
Region < ' tcx > ,
85
85
) ,
86
86
87
- /// Indicates a failure of a `PickConstraint `. These arise during
87
+ /// Indicates a failure of a `MemberConstraint `. These arise during
88
88
/// impl trait processing explicitly -- basically, the impl trait's hidden type
89
89
/// included some region that it was not supposed to.
90
- PickConstraintFailure {
90
+ MemberConstraintFailure {
91
91
span : Span ,
92
92
opaque_type_def_id : DefId ,
93
93
hidden_ty : Ty < ' tcx > ,
94
- pick_region : Region < ' tcx > ,
95
- option_regions : Vec < Region < ' tcx > > ,
94
+ member_region : Region < ' tcx > ,
95
+ choice_regions : Vec < Region < ' tcx > > ,
96
96
} ,
97
97
}
98
98
@@ -133,7 +133,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
133
133
self . expand_givens ( & graph) ;
134
134
loop {
135
135
self . expansion ( & mut var_data) ;
136
- if !self . enforce_pick_constraints ( & graph, & mut var_data) {
136
+ if !self . enforce_member_constraints ( & graph, & mut var_data) {
137
137
break ;
138
138
}
139
139
}
@@ -197,16 +197,16 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
197
197
}
198
198
}
199
199
200
- /// Enforce all pick constraints and return true if anything
201
- /// changed. See `enforce_pick_constraint ` for more details.
202
- fn enforce_pick_constraints (
200
+ /// Enforce all member constraints and return true if anything
201
+ /// changed. See `enforce_member_constraint ` for more details.
202
+ fn enforce_member_constraints (
203
203
& self ,
204
204
graph : & RegionGraph < ' tcx > ,
205
205
var_values : & mut LexicalRegionResolutions < ' tcx > ,
206
206
) -> bool {
207
207
let mut any_changed = false ;
208
- for pick_constraint in & self . data . pick_constraints {
209
- if self . enforce_pick_constraint ( graph, pick_constraint , var_values) {
208
+ for member_constraint in & self . data . member_constraints {
209
+ if self . enforce_member_constraint ( graph, member_constraint , var_values) {
210
210
any_changed = true ;
211
211
}
212
212
}
@@ -230,39 +230,44 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
230
230
///
231
231
/// From that list, we look for a *minimal* option `'o_min`. If we
232
232
/// find one, then we can enforce that `'r: 'o_min`.
233
- fn enforce_pick_constraint (
233
+ fn enforce_member_constraint (
234
234
& self ,
235
235
graph : & RegionGraph < ' tcx > ,
236
- pick_constraint : & PickConstraint < ' tcx > ,
236
+ member_constraint : & MemberConstraint < ' tcx > ,
237
237
var_values : & mut LexicalRegionResolutions < ' tcx > ,
238
238
) -> bool {
239
- debug ! ( "enforce_pick_constraint(pick_constraint ={:#?})" , pick_constraint ) ;
239
+ debug ! ( "enforce_member_constraint(member_constraint ={:#?})" , member_constraint ) ;
240
240
241
241
// the constraint is some inference variable (`vid`) which
242
242
// must be equal to one of the options
243
- let pick_vid = match pick_constraint . pick_region {
243
+ let member_vid = match member_constraint . member_region {
244
244
ty:: ReVar ( vid) => * vid,
245
245
_ => return false ,
246
246
} ;
247
247
248
248
// The current value of `vid` is a lower bound LB -- i.e., we
249
249
// know that `LB <= vid` must be true.
250
- let pick_lower_bound : ty:: Region < ' tcx > = match var_values. value ( pick_vid ) {
250
+ let member_lower_bound : ty:: Region < ' tcx > = match var_values. value ( member_vid ) {
251
251
VarValue :: ErrorValue => return false ,
252
252
VarValue :: Value ( r) => r,
253
253
} ;
254
254
255
255
// find all the "upper bounds" -- that is, each region `b` such that
256
256
// `r0 <= b` must hold.
257
- let ( pick_upper_bounds, _) = self . collect_concrete_regions ( graph, pick_vid, OUTGOING , None ) ;
257
+ let ( member_upper_bounds, _) = self . collect_concrete_regions (
258
+ graph,
259
+ member_vid,
260
+ OUTGOING ,
261
+ None ,
262
+ ) ;
258
263
259
- // get an iterator over the *available options * -- that is,
260
- // each constraint regions `o ` where `lb <= o ` and `o <= ub` for all the
264
+ // get an iterator over the *available choice * -- that is,
265
+ // each choice region `c ` where `lb <= c ` and `c <= ub` for all the
261
266
// upper bounds `ub`.
262
- debug ! ( "enforce_pick_constraint : upper_bounds={:#?}" , pick_upper_bounds ) ;
263
- let mut options = pick_constraint . option_regions . iter ( ) . filter ( |option| {
264
- self . sub_concrete_regions ( pick_lower_bound , option)
265
- && pick_upper_bounds
267
+ debug ! ( "enforce_member_constraint : upper_bounds={:#?}" , member_upper_bounds ) ;
268
+ let mut options = member_constraint . choice_regions . iter ( ) . filter ( |option| {
269
+ self . sub_concrete_regions ( member_lower_bound , option)
270
+ && member_upper_bounds
266
271
. iter ( )
267
272
. all ( |upper_bound| self . sub_concrete_regions ( option, upper_bound. region ) )
268
273
} ) ;
@@ -274,23 +279,23 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
274
279
Some ( & r) => r,
275
280
None => return false ,
276
281
} ;
277
- debug ! ( "enforce_pick_constraint : least_choice={:?}" , least_choice) ;
282
+ debug ! ( "enforce_member_constraint : least_choice={:?}" , least_choice) ;
278
283
for & option in options {
279
- debug ! ( "enforce_pick_constraint : option={:?}" , option) ;
284
+ debug ! ( "enforce_member_constraint : option={:?}" , option) ;
280
285
if !self . sub_concrete_regions ( least_choice, option) {
281
286
if self . sub_concrete_regions ( option, least_choice) {
282
- debug ! ( "enforce_pick_constraint : new least choice" ) ;
287
+ debug ! ( "enforce_member_constraint : new least choice" ) ;
283
288
least_choice = option;
284
289
} else {
285
- debug ! ( "enforce_pick_constraint : no least choice" ) ;
290
+ debug ! ( "enforce_member_constraint : no least choice" ) ;
286
291
return false ;
287
292
}
288
293
}
289
294
}
290
295
291
- debug ! ( "enforce_pick_constraint : final least choice = {:?}" , least_choice) ;
292
- if least_choice != pick_lower_bound {
293
- * var_values. value_mut ( pick_vid ) = VarValue :: Value ( least_choice) ;
296
+ debug ! ( "enforce_member_constraint : final least choice = {:?}" , least_choice) ;
297
+ if least_choice != member_lower_bound {
298
+ * var_values. value_mut ( member_vid ) = VarValue :: Value ( least_choice) ;
294
299
true
295
300
} else {
296
301
false
@@ -547,20 +552,20 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
547
552
}
548
553
}
549
554
550
- for pick_constraint in & self . data . pick_constraints {
551
- let pick_region = var_data. normalize ( self . tcx ( ) , pick_constraint . pick_region ) ;
552
- let option_regions = pick_constraint
553
- . option_regions
555
+ for member_constraint in & self . data . member_constraints {
556
+ let member_region = var_data. normalize ( self . tcx ( ) , member_constraint . member_region ) ;
557
+ let choice_regions = member_constraint
558
+ . choice_regions
554
559
. iter ( )
555
- . map ( |& option_region | var_data. normalize ( self . tcx ( ) , option_region ) ) ;
556
- if !option_regions . clone ( ) . any ( |option_region| pick_region == option_region ) {
557
- let span = self . tcx ( ) . def_span ( pick_constraint . opaque_type_def_id ) ;
558
- errors. push ( RegionResolutionError :: PickConstraintFailure {
560
+ . map ( |& choice_region | var_data. normalize ( self . tcx ( ) , choice_region ) ) ;
561
+ if !choice_regions . clone ( ) . any ( |choice_region| member_region == choice_region ) {
562
+ let span = self . tcx ( ) . def_span ( member_constraint . opaque_type_def_id ) ;
563
+ errors. push ( RegionResolutionError :: MemberConstraintFailure {
559
564
span,
560
- opaque_type_def_id : pick_constraint . opaque_type_def_id ,
561
- hidden_ty : pick_constraint . hidden_ty ,
562
- pick_region ,
563
- option_regions : option_regions . collect ( ) ,
565
+ opaque_type_def_id : member_constraint . opaque_type_def_id ,
566
+ hidden_ty : member_constraint . hidden_ty ,
567
+ member_region ,
568
+ choice_regions : choice_regions . collect ( ) ,
564
569
} ) ;
565
570
}
566
571
}
0 commit comments