Skip to content

Commit 9409bd9

Browse files
committed
Introduce predicates but don't use them.
1 parent 70be49d commit 9409bd9

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

src/librustc/metadata/decoder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,9 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc,
14371437
true
14381438
});
14391439

1440-
ty::Generics { types: types, regions: regions }
1440+
let predicates = subst::VecPerParamSpace::empty(); // TODO fix in later commit
1441+
1442+
ty::Generics { types: types, regions: regions, predicates: predicates }
14411443
}
14421444

14431445
pub fn is_associated_type(cdata: Cmd, id: ast::NodeId) -> bool {

src/librustc/middle/astencode.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,9 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
15541554
Ok(this.read_vec_per_param_space(
15551555
|this| Decodable::decode(this).unwrap()))
15561556
}).unwrap(),
1557+
1558+
predicates:
1559+
subst::VecPerParamSpace::empty(), // TODO fix in later commit
15571560
})
15581561
})
15591562
}).unwrap(),

src/librustc/middle/ty.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,13 +1619,30 @@ pub struct RegionParameterDef {
16191619
pub struct Generics<'tcx> {
16201620
pub types: VecPerParamSpace<TypeParameterDef<'tcx>>,
16211621
pub regions: VecPerParamSpace<RegionParameterDef>,
1622+
pub predicates: VecPerParamSpace<Predicate<'tcx>>,
1623+
}
1624+
1625+
#[deriving(Clone, Show)]
1626+
pub enum Predicate<'tcx> {
1627+
/// where Foo : Bar
1628+
Trait(Rc<TraitRef<'tcx>>),
1629+
1630+
/// where Foo == Bar
1631+
Equate(Ty<'tcx>, Ty<'tcx>),
1632+
1633+
/// where 'a : 'b
1634+
RegionOutlives(Region, Region),
1635+
1636+
/// where T : 'a
1637+
TypeOutlives(Ty<'tcx>, Region),
16221638
}
16231639

16241640
impl<'tcx> Generics<'tcx> {
16251641
pub fn empty() -> Generics<'tcx> {
16261642
Generics {
16271643
types: VecPerParamSpace::empty(),
16281644
regions: VecPerParamSpace::empty(),
1645+
predicates: VecPerParamSpace::empty(),
16291646
}
16301647
}
16311648

src/librustc/middle/ty_fold.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,25 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Generics<'tcx> {
399399
ty::Generics {
400400
types: self.types.fold_with(folder),
401401
regions: self.regions.fold_with(folder),
402+
predicates: self.predicates.fold_with(folder),
403+
}
404+
}
405+
}
406+
407+
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
408+
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::Predicate<'tcx> {
409+
match *self {
410+
ty::Predicate::Trait(ref a) =>
411+
ty::Predicate::Trait(a.fold_with(folder)),
412+
ty::Predicate::Equate(ref a, ref b) =>
413+
ty::Predicate::Equate(a.fold_with(folder),
414+
b.fold_with(folder)),
415+
ty::Predicate::RegionOutlives(ref a, ref b) =>
416+
ty::Predicate::RegionOutlives(a.fold_with(folder),
417+
b.fold_with(folder)),
418+
ty::Predicate::TypeOutlives(ref a, ref b) =>
419+
ty::Predicate::TypeOutlives(a.fold_with(folder),
420+
b.fold_with(folder)),
402421
}
403422
}
404423
}

src/librustc_typeck/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ fn no_params<'tcx>(t: Ty<'tcx>) -> ty::Polytype<'tcx> {
163163
generics: ty::Generics {
164164
types: VecPerParamSpace::empty(),
165165
regions: VecPerParamSpace::empty(),
166+
predicates: VecPerParamSpace::empty(),
166167
},
167168
ty: t
168169
}

0 commit comments

Comments
 (0)