Implement generalized object and type parameter bounds (Fixes #16462)

This commit is contained in:
Niko Matsakis 2014-08-27 21:46:52 -04:00
parent 3ee047ae1f
commit 1b487a8906
272 changed files with 6783 additions and 3154 deletions

View file

@ -68,10 +68,15 @@ impl<'a> Iterator<PathElem> for LinkedPath<'a> {
}
}
// HACK(eddyb) move this into libstd (value wrapper for slice::Items).
#[cfg(stage0)]
#[deriving(Clone)]
pub struct Values<'a, T>(pub slice::Items<'a, T>);
// HACK(eddyb) move this into libstd (value wrapper for slice::Items).
#[cfg(not(stage0))]
#[deriving(Clone)]
pub struct Values<'a, T:'a>(pub slice::Items<'a, T>);
impl<'a, T: Copy> Iterator<T> for Values<'a, T> {
fn next(&mut self) -> Option<T> {
let &Values(ref mut items) = self;
@ -478,6 +483,7 @@ impl Map {
}
}
#[cfg(stage0)]
pub struct NodesMatchingSuffix<'a, S> {
map: &'a Map,
item_name: &'a S,
@ -485,6 +491,14 @@ pub struct NodesMatchingSuffix<'a, S> {
idx: NodeId,
}
#[cfg(not(stage0))]
pub struct NodesMatchingSuffix<'a, S:'a> {
map: &'a Map,
item_name: &'a S,
in_which: &'a [S],
idx: NodeId,
}
impl<'a,S:Str> NodesMatchingSuffix<'a,S> {
/// Returns true only if some suffix of the module path for parent
/// matches `self.in_which`.
@ -676,11 +690,7 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
None => {}
}
}
ItemTrait(_, _, ref traits, ref methods) => {
for t in traits.iter() {
self.insert(t.ref_id, EntryItem(self.parent, i));
}
ItemTrait(_, _, _, ref methods) => {
for tm in methods.iter() {
match *tm {
RequiredMethod(ref m) => {