10
10
11
11
// #![warn(deprecated_mode)]
12
12
13
- pub use self :: WfConstraint :: * ;
14
-
15
13
use astconv:: object_region_bounds;
16
14
use middle:: infer:: GenericKind ;
17
15
use middle:: subst:: { ParamSpace , Subst , Substs } ;
@@ -24,37 +22,37 @@ use util::ppaux::Repr;
24
22
25
23
// Helper functions related to manipulating region types.
26
24
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 > ) ,
30
28
}
31
29
32
- struct Wf < ' a , ' tcx : ' a > {
30
+ struct Implicator < ' a , ' tcx : ' a > {
33
31
tcx : & ' a ty:: ctxt < ' tcx > ,
34
32
stack : Vec < ( ty:: Region , Option < Ty < ' tcx > > ) > ,
35
- out : Vec < WfConstraint < ' tcx > > ,
33
+ out : Vec < Implication < ' tcx > > ,
36
34
}
37
35
38
36
/// This routine computes the well-formedness constraints that must hold for the type `ty` to
39
37
/// appear in a context with lifetime `outer_region`
40
- pub fn region_wf_constraints < ' tcx > (
38
+ pub fn implications < ' tcx > (
41
39
tcx : & ty:: ctxt < ' tcx > ,
42
40
ty : Ty < ' tcx > ,
43
41
outer_region : ty:: Region )
44
- -> Vec < WfConstraint < ' tcx > >
42
+ -> Vec < Implication < ' tcx > >
45
43
{
46
44
let mut stack = Vec :: new ( ) ;
47
45
stack. push ( ( outer_region, None ) ) ;
48
- let mut wf = Wf { tcx : tcx,
46
+ let mut wf = Implicator { tcx : tcx,
49
47
stack : stack,
50
48
out : Vec :: new ( ) } ;
51
49
wf. accumulate_from_ty ( ty) ;
52
50
wf. out
53
51
}
54
52
55
- impl < ' a , ' tcx > Wf < ' a , ' tcx > {
53
+ impl < ' a , ' tcx > Implicator < ' a , ' tcx > {
56
54
fn accumulate_from_ty ( & mut self , ty : Ty < ' tcx > ) {
57
- debug ! ( "Wf:: accumulate_from_ty(ty={})" ,
55
+ debug ! ( "accumulate_from_ty(ty={})" ,
58
56
ty. repr( self . tcx) ) ;
59
57
60
58
match ty. sty {
@@ -197,7 +195,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
197
195
opt_ty : Option < Ty < ' tcx > > ,
198
196
r_a : ty:: Region ,
199
197
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) ) ;
201
199
}
202
200
203
201
/// Pushes a constraint that `param_ty` must outlive the top region on the stack.
@@ -211,7 +209,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
211
209
fn push_projection_constraint_from_top ( & mut self ,
212
210
projection_ty : & ty:: ProjectionTy < ' tcx > ) {
213
211
let & ( region, opt_ty) = self . stack . last ( ) . unwrap ( ) ;
214
- self . out . push ( RegionSubGenericConstraint (
212
+ self . out . push ( Implication :: RegionSubGeneric (
215
213
opt_ty, region, GenericKind :: Projection ( projection_ty. clone ( ) ) ) ) ;
216
214
}
217
215
@@ -220,7 +218,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
220
218
region : ty:: Region ,
221
219
opt_ty : Option < Ty < ' tcx > > ,
222
220
param_ty : ty:: ParamTy ) {
223
- self . out . push ( RegionSubGenericConstraint (
221
+ self . out . push ( Implication :: RegionSubGeneric (
224
222
opt_ty, region, GenericKind :: Param ( param_ty) ) ) ;
225
223
}
226
224
@@ -372,22 +370,22 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
372
370
for & r_d in & required_region_bounds {
373
371
// Each of these is an instance of the `'c <= 'b`
374
372
// 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) ) ;
376
374
}
377
375
}
378
376
}
379
377
380
- impl < ' tcx > Repr < ' tcx > for WfConstraint < ' tcx > {
378
+ impl < ' tcx > Repr < ' tcx > for Implication < ' tcx > {
381
379
fn repr ( & self , tcx : & ty:: ctxt < ' tcx > ) -> String {
382
380
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 ({}, {})" ,
385
383
r_a. repr( tcx) ,
386
384
r_b. repr( tcx) )
387
385
}
388
386
389
- RegionSubGenericConstraint ( _, ref r, ref p) => {
390
- format ! ( "RegionSubGenericConstraint ({}, {})" ,
387
+ Implication :: RegionSubGeneric ( _, ref r, ref p) => {
388
+ format ! ( "RegionSubGeneric ({}, {})" ,
391
389
r. repr( tcx) ,
392
390
p. repr( tcx) )
393
391
}
0 commit comments