Resolve trait associated items

E.g. `Default::default` or `<Foo as Default>::default`.
This commit is contained in:
Florian Diebold 2019-09-25 21:41:17 +02:00
parent 5704485063
commit c35ef5013c
5 changed files with 78 additions and 19 deletions

View file

@ -1055,3 +1055,13 @@ pub enum AssocItem {
// require not implementing From, and instead having some checked way of
// casting them, and somehow making the constructors private, which would be annoying.
impl_froms!(AssocItem: Function, Const, TypeAlias);
impl From<AssocItem> for crate::generics::GenericDef {
fn from(item: AssocItem) -> Self {
match item {
AssocItem::Function(f) => f.into(),
AssocItem::Const(c) => c.into(),
AssocItem::TypeAlias(t) => t.into(),
}
}
}