Skip to content

Commit 92d65ab

Browse files
committed
Rename various things to "implications"
1 parent df92fe3 commit 92d65ab

File tree

2 files changed

+36
-46
lines changed

2 files changed

+36
-46
lines changed

src/librustc_typeck/check/implicator.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// #![warn(deprecated_mode)]
1212

13-
pub use self::WfConstraint::*;
14-
1513
use astconv::object_region_bounds;
1614
use middle::infer::GenericKind;
1715
use middle::subst::{ParamSpace, Subst, Substs};
@@ -24,37 +22,37 @@ use util::ppaux::Repr;
2422

2523
// Helper functions related to manipulating region types.
2624

27-
pub enum WfConstraint<'tcx> {
28-
RegionSubRegionConstraint(Option<Ty<'tcx>>, ty::Region, ty::Region),
29-
RegionSubGenericConstraint(Option<Ty<'tcx>>, ty::Region, GenericKind<'tcx>),
25+
pub enum Implication<'tcx> {
26+
RegionSubRegion(Option<Ty<'tcx>>, ty::Region, ty::Region),
27+
RegionSubGeneric(Option<Ty<'tcx>>, ty::Region, GenericKind<'tcx>),
3028
}
3129

32-
struct Wf<'a, 'tcx: 'a> {
30+
struct Implicator<'a, 'tcx: 'a> {
3331
tcx: &'a ty::ctxt<'tcx>,
3432
stack: Vec<(ty::Region, Option<Ty<'tcx>>)>,
35-
out: Vec<WfConstraint<'tcx>>,
33+
out: Vec<Implication<'tcx>>,
3634
}
3735

3836
/// This routine computes the well-formedness constraints that must hold for the type `ty` to
3937
/// appear in a context with lifetime `outer_region`
40-
pub fn region_wf_constraints<'tcx>(
38+
pub fn implications<'tcx>(
4139
tcx: &ty::ctxt<'tcx>,
4240
ty: Ty<'tcx>,
4341
outer_region: ty::Region)
44-
-> Vec<WfConstraint<'tcx>>
42+
-> Vec<Implication<'tcx>>
4543
{
4644
let mut stack = Vec::new();
4745
stack.push((outer_region, None));
48-
let mut wf = Wf { tcx: tcx,
46+
let mut wf = Implicator { tcx: tcx,
4947
stack: stack,
5048
out: Vec::new() };
5149
wf.accumulate_from_ty(ty);
5250
wf.out
5351
}
5452

55-
impl<'a, 'tcx> Wf<'a, 'tcx> {
53+
impl<'a, 'tcx> Implicator<'a, 'tcx> {
5654
fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
57-
debug!("Wf::accumulate_from_ty(ty={})",
55+
debug!("accumulate_from_ty(ty={})",
5856
ty.repr(self.tcx));
5957

6058
match ty.sty {
@@ -197,7 +195,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
197195
opt_ty: Option<Ty<'tcx>>,
198196
r_a: ty::Region,
199197
r_b: ty::Region) {
200-
self.out.push(RegionSubRegionConstraint(opt_ty, r_a, r_b));
198+
self.out.push(Implication::RegionSubRegion(opt_ty, r_a, r_b));
201199
}
202200

203201
/// Pushes a constraint that `param_ty` must outlive the top region on the stack.
@@ -211,7 +209,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
211209
fn push_projection_constraint_from_top(&mut self,
212210
projection_ty: &ty::ProjectionTy<'tcx>) {
213211
let &(region, opt_ty) = self.stack.last().unwrap();
214-
self.out.push(RegionSubGenericConstraint(
212+
self.out.push(Implication::RegionSubGeneric(
215213
opt_ty, region, GenericKind::Projection(projection_ty.clone())));
216214
}
217215

@@ -220,7 +218,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
220218
region: ty::Region,
221219
opt_ty: Option<Ty<'tcx>>,
222220
param_ty: ty::ParamTy) {
223-
self.out.push(RegionSubGenericConstraint(
221+
self.out.push(Implication::RegionSubGeneric(
224222
opt_ty, region, GenericKind::Param(param_ty)));
225223
}
226224

@@ -372,22 +370,22 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
372370
for &r_d in &required_region_bounds {
373371
// Each of these is an instance of the `'c <= 'b`
374372
// constraint above
375-
self.out.push(RegionSubRegionConstraint(Some(ty), r_d, r_c));
373+
self.out.push(Implication::RegionSubRegion(Some(ty), r_d, r_c));
376374
}
377375
}
378376
}
379377

380-
impl<'tcx> Repr<'tcx> for WfConstraint<'tcx> {
378+
impl<'tcx> Repr<'tcx> for Implication<'tcx> {
381379
fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
382380
match *self {
383-
RegionSubRegionConstraint(_, ref r_a, ref r_b) => {
384-
format!("RegionSubRegionConstraint({}, {})",
381+
Implication::RegionSubRegion(_, ref r_a, ref r_b) => {
382+
format!("RegionSubRegion({}, {})",
385383
r_a.repr(tcx),
386384
r_b.repr(tcx))
387385
}
388386

389-
RegionSubGenericConstraint(_, ref r, ref p) => {
390-
format!("RegionSubGenericConstraint({}, {})",
387+
Implication::RegionSubGeneric(_, ref r, ref p) => {
388+
format!("RegionSubGeneric({}, {})",
391389
r.repr(tcx),
392390
p.repr(tcx))
393391
}

src/librustc_typeck/check/regionck.rs

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -335,25 +335,21 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
335335
debug!("relate_free_regions(t={})", ty.repr(tcx));
336336
let body_scope = CodeExtent::from_node_id(body_id);
337337
let body_scope = ty::ReScope(body_scope);
338-
let constraints =
339-
implicator::region_wf_constraints(
340-
tcx,
341-
ty,
342-
body_scope);
343-
for constraint in &constraints {
344-
debug!("constraint: {}", constraint.repr(tcx));
345-
match *constraint {
346-
implicator::RegionSubRegionConstraint(_,
338+
let implications = implicator::implications(tcx, ty, body_scope);
339+
for implication in implications {
340+
debug!("implication: {}", implication.repr(tcx));
341+
match implication {
342+
implicator::Implication::RegionSubRegion(_,
347343
ty::ReFree(free_a),
348344
ty::ReFree(free_b)) => {
349345
tcx.region_maps.relate_free_regions(free_a, free_b);
350346
}
351-
implicator::RegionSubRegionConstraint(_,
347+
implicator::Implication::RegionSubRegion(_,
352348
ty::ReFree(free_a),
353349
ty::ReInfer(ty::ReVar(vid_b))) => {
354350
self.fcx.inh.infcx.add_given(free_a, vid_b);
355351
}
356-
implicator::RegionSubRegionConstraint(..) => {
352+
implicator::Implication::RegionSubRegion(..) => {
357353
// In principle, we could record (and take
358354
// advantage of) every relationship here, but
359355
// we are also free not to -- it simply means
@@ -364,8 +360,8 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
364360
// relationship that arises here, but
365361
// presently we do not.)
366362
}
367-
implicator::RegionSubGenericConstraint(_, r_a, ref generic_b) => {
368-
debug!("RegionSubGenericConstraint: {} <= {}",
363+
implicator::Implication::RegionSubGeneric(_, r_a, ref generic_b) => {
364+
debug!("RegionSubGeneric: {} <= {}",
369365
r_a.repr(tcx), generic_b.repr(tcx));
370366

371367
self.region_bound_pairs.push((r_a, generic_b.clone()));
@@ -1481,25 +1477,21 @@ pub fn type_must_outlive<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
14811477
ty.repr(rcx.tcx()),
14821478
region.repr(rcx.tcx()));
14831479

1484-
let constraints =
1485-
implicator::region_wf_constraints(
1486-
rcx.tcx(),
1487-
ty,
1488-
region);
1489-
for constraint in &constraints {
1490-
debug!("constraint: {}", constraint.repr(rcx.tcx()));
1491-
match *constraint {
1492-
implicator::RegionSubRegionConstraint(None, r_a, r_b) => {
1480+
let implications = implicator::implications(rcx.tcx(), ty, region);
1481+
for implication in implications {
1482+
debug!("implication: {}", implication.repr(rcx.tcx()));
1483+
match implication {
1484+
implicator::Implication::RegionSubRegion(None, r_a, r_b) => {
14931485
rcx.fcx.mk_subr(origin.clone(), r_a, r_b);
14941486
}
1495-
implicator::RegionSubRegionConstraint(Some(ty), r_a, r_b) => {
1487+
implicator::Implication::RegionSubRegion(Some(ty), r_a, r_b) => {
14961488
let o1 = infer::ReferenceOutlivesReferent(ty, origin.span());
14971489
rcx.fcx.mk_subr(o1, r_a, r_b);
14981490
}
1499-
implicator::RegionSubGenericConstraint(None, r_a, ref generic_b) => {
1491+
implicator::Implication::RegionSubGeneric(None, r_a, ref generic_b) => {
15001492
generic_must_outlive(rcx, origin.clone(), r_a, generic_b);
15011493
}
1502-
implicator::RegionSubGenericConstraint(Some(ty), r_a, ref generic_b) => {
1494+
implicator::Implication::RegionSubGeneric(Some(ty), r_a, ref generic_b) => {
15031495
let o1 = infer::ReferenceOutlivesReferent(ty, origin.span());
15041496
generic_must_outlive(rcx, o1, r_a, generic_b);
15051497
}

0 commit comments

Comments
 (0)