From bcf30d389c3744ab517372431eb7e1e1dfcc50df Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 13 Sep 2019 00:31:04 +0300 Subject: generalize impl_froms to nested enums --- crates/ra_hir/src/ty/lower.rs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index 587dc12ee..105c893f0 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs @@ -611,25 +611,15 @@ pub enum TypableDef { Static(Static), BuiltinType(BuiltinType), } -impl_froms!(TypableDef: Function, AdtDef, EnumVariant, TypeAlias, Const, Static, BuiltinType); - -impl From for TypableDef { - fn from(it: Struct) -> TypableDef { - TypableDef::AdtDef(AdtDef::Struct(it)) - } -} - -impl From for TypableDef { - fn from(it: Enum) -> TypableDef { - TypableDef::AdtDef(AdtDef::Enum(it)) - } -} - -impl From for TypableDef { - fn from(it: Union) -> TypableDef { - TypableDef::AdtDef(AdtDef::Union(it)) - } -} +impl_froms!( + TypableDef: Function, + AdtDef(Struct, Enum, Union), + EnumVariant, + TypeAlias, + Const, + Static, + BuiltinType +); impl From for Option { fn from(def: ModuleDef) -> Option { -- cgit v1.2.3