Skip to content

Commit eca55b5

Browse files
committed
rename to "member constraints"
1 parent e39f66a commit eca55b5

File tree

14 files changed

+275
-261
lines changed

14 files changed

+275
-261
lines changed

src/librustc/infer/canonical/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVariableOriginKind};
2525
use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
26-
use crate::infer::region_constraints::PickConstraint;
26+
use crate::infer::region_constraints::MemberConstraint;
2727
use crate::mir::interpret::ConstValue;
2828
use rustc_data_structures::indexed_vec::IndexVec;
2929
use rustc_macros::HashStable;
@@ -198,14 +198,14 @@ pub struct QueryResponse<'tcx, R> {
198198
#[derive(Clone, Debug, Default, HashStable)]
199199
pub struct QueryRegionConstraints<'tcx> {
200200
pub outlives: Vec<QueryOutlivesConstraint<'tcx>>,
201-
pub pick_constraints: Vec<PickConstraint<'tcx>>,
201+
pub member_constraints: Vec<MemberConstraint<'tcx>>,
202202
}
203203

204204
impl QueryRegionConstraints<'_> {
205205
/// Represents an empty (trivially true) set of region
206206
/// constraints.
207207
pub fn is_empty(&self) -> bool {
208-
self.outlives.is_empty() && self.pick_constraints.is_empty()
208+
self.outlives.is_empty() && self.member_constraints.is_empty()
209209
}
210210
}
211211

@@ -558,14 +558,14 @@ BraceStructLiftImpl! {
558558

559559
BraceStructTypeFoldableImpl! {
560560
impl<'tcx> TypeFoldable<'tcx> for QueryRegionConstraints<'tcx> {
561-
outlives, pick_constraints
561+
outlives, member_constraints
562562
}
563563
}
564564

565565
BraceStructLiftImpl! {
566566
impl<'a, 'tcx> Lift<'tcx> for QueryRegionConstraints<'a> {
567567
type Lifted = QueryRegionConstraints<'tcx>;
568-
outlives, pick_constraints
568+
outlives, member_constraints
569569
}
570570
}
571571

src/librustc/infer/canonical/query_response.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
351351
})
352352
);
353353

354-
// ...also include the query pick constraints.
355-
output_query_region_constraints.pick_constraints.extend(
356-
query_response.value.region_constraints.pick_constraints.iter().map(|p_c| {
354+
// ...also include the query member constraints.
355+
output_query_region_constraints.member_constraints.extend(
356+
query_response.value.region_constraints.member_constraints.iter().map(|p_c| {
357357
substitute_value(self.tcx, &result_subst, p_c)
358358
})
359359
);
@@ -663,7 +663,7 @@ pub fn make_query_region_constraints<'tcx>(
663663
constraints,
664664
verifys,
665665
givens,
666-
pick_constraints,
666+
member_constraints,
667667
} = region_constraints;
668668

669669
assert!(verifys.is_empty());
@@ -694,5 +694,5 @@ pub fn make_query_region_constraints<'tcx>(
694694
)
695695
.collect();
696696

697-
QueryRegionConstraints { outlives, pick_constraints: pick_constraints.clone() }
697+
QueryRegionConstraints { outlives, member_constraints: member_constraints.clone() }
698698
}

src/librustc/infer/error_reporting/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,20 +377,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
377377
}
378378
}
379379

380-
RegionResolutionError::PickConstraintFailure {
380+
RegionResolutionError::MemberConstraintFailure {
381381
opaque_type_def_id,
382382
hidden_ty,
383-
pick_region,
383+
member_region,
384384
span: _,
385-
option_regions: _,
385+
choice_regions: _,
386386
} => {
387387
let hidden_ty = self.resolve_vars_if_possible(&hidden_ty);
388388
opaque_types::unexpected_hidden_region_diagnostic(
389389
self.tcx,
390390
Some(region_scope_tree),
391391
opaque_type_def_id,
392392
hidden_ty,
393-
pick_region,
393+
member_region,
394394
).emit();
395395
}
396396
}
@@ -430,7 +430,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
430430
RegionResolutionError::GenericBoundFailure(..) => true,
431431
RegionResolutionError::ConcreteFailure(..)
432432
| RegionResolutionError::SubSupConflict(..)
433-
| RegionResolutionError::PickConstraintFailure { .. } => false,
433+
| RegionResolutionError::MemberConstraintFailure { .. } => false,
434434
};
435435

436436
let mut errors = if errors.iter().all(|e| is_bound_failure(e)) {
@@ -448,7 +448,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
448448
RegionResolutionError::ConcreteFailure(ref sro, _, _) => sro.span(),
449449
RegionResolutionError::GenericBoundFailure(ref sro, _, _) => sro.span(),
450450
RegionResolutionError::SubSupConflict(_, ref rvo, _, _, _, _) => rvo.span(),
451-
RegionResolutionError::PickConstraintFailure { span, .. } => span,
451+
RegionResolutionError::MemberConstraintFailure { span, .. } => span,
452452
});
453453
errors
454454
}

src/librustc/infer/lexical_region_resolve/mod.rs

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::hir::def_id::DefId;
44
use crate::infer::region_constraints::Constraint;
55
use crate::infer::region_constraints::GenericKind;
6-
use crate::infer::region_constraints::PickConstraint;
6+
use crate::infer::region_constraints::MemberConstraint;
77
use crate::infer::region_constraints::RegionConstraintData;
88
use crate::infer::region_constraints::VarInfos;
99
use crate::infer::region_constraints::VerifyBound;
@@ -84,15 +84,15 @@ pub enum RegionResolutionError<'tcx> {
8484
Region<'tcx>,
8585
),
8686

87-
/// Indicates a failure of a `PickConstraint`. These arise during
87+
/// Indicates a failure of a `MemberConstraint`. These arise during
8888
/// impl trait processing explicitly -- basically, the impl trait's hidden type
8989
/// included some region that it was not supposed to.
90-
PickConstraintFailure {
90+
MemberConstraintFailure {
9191
span: Span,
9292
opaque_type_def_id: DefId,
9393
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>>,
9696
},
9797
}
9898

@@ -133,7 +133,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
133133
self.expand_givens(&graph);
134134
loop {
135135
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) {
137137
break;
138138
}
139139
}
@@ -197,16 +197,16 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
197197
}
198198
}
199199

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(
203203
&self,
204204
graph: &RegionGraph<'tcx>,
205205
var_values: &mut LexicalRegionResolutions<'tcx>,
206206
) -> bool {
207207
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) {
210210
any_changed = true;
211211
}
212212
}
@@ -230,39 +230,44 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
230230
///
231231
/// From that list, we look for a *minimal* option `'o_min`. If we
232232
/// find one, then we can enforce that `'r: 'o_min`.
233-
fn enforce_pick_constraint(
233+
fn enforce_member_constraint(
234234
&self,
235235
graph: &RegionGraph<'tcx>,
236-
pick_constraint: &PickConstraint<'tcx>,
236+
member_constraint: &MemberConstraint<'tcx>,
237237
var_values: &mut LexicalRegionResolutions<'tcx>,
238238
) -> bool {
239-
debug!("enforce_pick_constraint(pick_constraint={:#?})", pick_constraint);
239+
debug!("enforce_member_constraint(member_constraint={:#?})", member_constraint);
240240

241241
// the constraint is some inference variable (`vid`) which
242242
// 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 {
244244
ty::ReVar(vid) => *vid,
245245
_ => return false,
246246
};
247247

248248
// The current value of `vid` is a lower bound LB -- i.e., we
249249
// 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) {
251251
VarValue::ErrorValue => return false,
252252
VarValue::Value(r) => r,
253253
};
254254

255255
// find all the "upper bounds" -- that is, each region `b` such that
256256
// `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+
);
258263

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
261266
// 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
266271
.iter()
267272
.all(|upper_bound| self.sub_concrete_regions(option, upper_bound.region))
268273
});
@@ -274,23 +279,23 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
274279
Some(&r) => r,
275280
None => return false,
276281
};
277-
debug!("enforce_pick_constraint: least_choice={:?}", least_choice);
282+
debug!("enforce_member_constraint: least_choice={:?}", least_choice);
278283
for &option in options {
279-
debug!("enforce_pick_constraint: option={:?}", option);
284+
debug!("enforce_member_constraint: option={:?}", option);
280285
if !self.sub_concrete_regions(least_choice, option) {
281286
if self.sub_concrete_regions(option, least_choice) {
282-
debug!("enforce_pick_constraint: new least choice");
287+
debug!("enforce_member_constraint: new least choice");
283288
least_choice = option;
284289
} else {
285-
debug!("enforce_pick_constraint: no least choice");
290+
debug!("enforce_member_constraint: no least choice");
286291
return false;
287292
}
288293
}
289294
}
290295

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);
294299
true
295300
} else {
296301
false
@@ -547,20 +552,20 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
547552
}
548553
}
549554

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
554559
.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 {
559564
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(),
564569
});
565570
}
566571
}

src/librustc/infer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,17 +907,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
907907

908908
/// Require that the region `r` be equal to one of the regions in
909909
/// the set `regions`.
910-
pub fn pick_constraint(
910+
pub fn member_constraint(
911911
&self,
912912
opaque_type_def_id: DefId,
913913
definition_span: Span,
914914
hidden_ty: Ty<'tcx>,
915915
region: ty::Region<'tcx>,
916916
in_regions: &Lrc<Vec<ty::Region<'tcx>>>,
917917
) {
918-
debug!("pick_constraint({:?} <: {:?})", region, in_regions);
918+
debug!("member_constraint({:?} <: {:?})", region, in_regions);
919919
self.borrow_region_constraints()
920-
.pick_constraint(opaque_type_def_id, definition_span, hidden_ty, region, in_regions);
920+
.member_constraint(opaque_type_def_id, definition_span, hidden_ty, region, in_regions);
921921
}
922922

923923
pub fn subtype_predicate(

src/librustc/infer/opaque_types/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
393393
// we will create a "in bound" like `'r in
394394
// ['a, 'b, 'c]`, where `'a..'c` are the
395395
// regions that appear in the impl trait.
396-
return self.generate_pick_constraint(
396+
return self.generate_member_constraint(
397397
concrete_ty,
398398
abstract_type_generics,
399399
opaque_defn,
@@ -418,17 +418,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
418418
/// related, we would generate a constraint `'r in ['a, 'b,
419419
/// 'static]` for each region `'r` that appears in the hidden type
420420
/// (i.e., it must be equal to `'a`, `'b`, or `'static`).
421-
fn generate_pick_constraint(
421+
fn generate_member_constraint(
422422
&self,
423423
concrete_ty: Ty<'tcx>,
424424
abstract_type_generics: &ty::Generics,
425425
opaque_defn: &OpaqueTypeDecl<'tcx>,
426426
opaque_type_def_id: DefId,
427427
) {
428-
// Create the set of option regions: each region in the hidden
428+
// Create the set of choice regions: each region in the hidden
429429
// type can be equal to any of the region parameters of the
430430
// opaque type definition.
431-
let option_regions: Lrc<Vec<ty::Region<'tcx>>> = Lrc::new(
431+
let choice_regions: Lrc<Vec<ty::Region<'tcx>>> = Lrc::new(
432432
abstract_type_generics
433433
.params
434434
.iter()
@@ -443,12 +443,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
443443

444444
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
445445
tcx: self.tcx,
446-
op: |r| self.pick_constraint(
446+
op: |r| self.member_constraint(
447447
opaque_type_def_id,
448448
opaque_defn.definition_span,
449449
concrete_ty,
450450
r,
451-
&option_regions,
451+
&choice_regions,
452452
),
453453
});
454454
}

0 commit comments

Comments
 (0)