stub out trait aliases in resolve

This commit is contained in:
Alex Burka 2017-10-02 13:48:57 +00:00 committed by Alex Burka
parent d4a28268cc
commit f1c4a922fe
2 changed files with 18 additions and 0 deletions

View File

@ -344,6 +344,11 @@ impl<'a> Resolver<'a> {
}
}
ItemKind::TraitAlias(..) => {
let def = Def::TraitAlias(self.definitions.local_def_id(item.id));
self.define(parent, ident, TypeNS, (def, vis, sp, expansion));
}
// These items live in both the type and value namespaces.
ItemKind::Struct(ref struct_def, _) => {
// Define a name in the type namespace.
@ -411,6 +416,7 @@ impl<'a> Resolver<'a> {
self.define(parent, ident, TypeNS, (module, vis, sp, expansion));
self.current_module = module;
}
ItemKind::MacroDef(..) | ItemKind::Mac(_) => unreachable!(),
}
}

View File

@ -474,6 +474,7 @@ impl<'a> PathSource<'a> {
},
PathSource::Trait => match def {
Def::Trait(..) => true,
Def::TraitAlias(..) => true,
_ => false,
},
PathSource::Expr(..) => match def {
@ -1935,6 +1936,17 @@ impl<'a> Resolver<'a> {
});
}
ItemKind::TraitAlias(ref generics, ref bounds) => {
// Create a new rib for the trait-wide type parameters.
self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
let local_def_id = this.definitions.local_def_id(item.id);
this.with_self_rib(Def::SelfTy(Some(local_def_id), None), |this| {
this.visit_generics(generics);
walk_list!(this, visit_ty_param_bound, bounds);
});
});
}
ItemKind::Mod(_) | ItemKind::ForeignMod(_) => {
self.with_scope(item.id, |this| {
visit::walk_item(this, item);