aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs20
-rw-r--r--crates/ra_hir/src/generics.rs27
-rw-r--r--crates/ra_hir/src/lib.rs9
-rw-r--r--crates/ra_hir/src/ty/lower.rs28
4 files changed, 26 insertions, 58 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 026753c9f..a10e795ce 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -139,7 +139,7 @@ pub enum ModuleDef {
139impl_froms!( 139impl_froms!(
140 ModuleDef: Module, 140 ModuleDef: Module,
141 Function, 141 Function,
142 AdtDef, 142 AdtDef(Struct, Enum, Union),
143 EnumVariant, 143 EnumVariant,
144 Const, 144 Const,
145 Static, 145 Static,
@@ -148,24 +148,6 @@ impl_froms!(
148 BuiltinType 148 BuiltinType
149); 149);
150 150
151impl From<Struct> for ModuleDef {
152 fn from(it: Struct) -> ModuleDef {
153 ModuleDef::AdtDef(AdtDef::Struct(it))
154 }
155}
156
157impl From<Enum> for ModuleDef {
158 fn from(it: Enum) -> ModuleDef {
159 ModuleDef::AdtDef(AdtDef::Enum(it))
160 }
161}
162
163impl From<Union> for ModuleDef {
164 fn from(it: Union) -> ModuleDef {
165 ModuleDef::AdtDef(AdtDef::Union(it))
166 }
167}
168
169pub enum ModuleSource { 151pub enum ModuleSource {
170 SourceFile(ast::SourceFile), 152 SourceFile(ast::SourceFile),
171 Module(ast::Module), 153 Module(ast::Module),
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index 0e89941f3..74435c20a 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -55,25 +55,14 @@ pub enum GenericDef {
55 // can, and this makes some code easier to write 55 // can, and this makes some code easier to write
56 EnumVariant(EnumVariant), 56 EnumVariant(EnumVariant),
57} 57}
58impl_froms!(GenericDef: Function, AdtDef, Trait, TypeAlias, ImplBlock, EnumVariant); 58impl_froms!(
59 59 GenericDef: Function,
60impl From<Struct> for GenericDef { 60 AdtDef(Struct, Enum, Union),
61 fn from(it: Struct) -> GenericDef { 61 Trait,
62 GenericDef::AdtDef(AdtDef::Struct(it)) 62 TypeAlias,
63 } 63 ImplBlock,
64} 64 EnumVariant
65 65);
66impl From<Enum> for GenericDef {
67 fn from(it: Enum) -> GenericDef {
68 GenericDef::AdtDef(AdtDef::Enum(it))
69 }
70}
71
72impl From<Union> for GenericDef {
73 fn from(it: Union) -> GenericDef {
74 GenericDef::AdtDef(AdtDef::Union(it))
75 }
76}
77 66
78impl GenericParams { 67impl GenericParams {
79 pub(crate) fn generic_params_query( 68 pub(crate) fn generic_params_query(
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 2fe1a658e..639e97c3d 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -8,13 +8,20 @@
8//! applied. So, the relation between syntax and HIR is many-to-one. 8//! applied. So, the relation between syntax and HIR is many-to-one.
9 9
10macro_rules! impl_froms { 10macro_rules! impl_froms {
11 ($e:ident: $($v:ident),*) => { 11 ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => {
12 $( 12 $(
13 impl From<$v> for $e { 13 impl From<$v> for $e {
14 fn from(it: $v) -> $e { 14 fn from(it: $v) -> $e {
15 $e::$v(it) 15 $e::$v(it)
16 } 16 }
17 } 17 }
18 $($(
19 impl From<$sv> for $e {
20 fn from(it: $sv) -> $e {
21 $e::$v($v::$sv(it))
22 }
23 }
24 )*)?
18 )* 25 )*
19 } 26 }
20} 27}
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 {
611 Static(Static), 611 Static(Static),
612 BuiltinType(BuiltinType), 612 BuiltinType(BuiltinType),
613} 613}
614impl_froms!(TypableDef: Function, AdtDef, EnumVariant, TypeAlias, Const, Static, BuiltinType); 614impl_froms!(
615 615 TypableDef: Function,
616impl From<Struct> for TypableDef { 616 AdtDef(Struct, Enum, Union),
617 fn from(it: Struct) -> TypableDef { 617 EnumVariant,
618 TypableDef::AdtDef(AdtDef::Struct(it)) 618 TypeAlias,
619 } 619 Const,
620} 620 Static,
621 621 BuiltinType
622impl From<Enum> for TypableDef { 622);
623 fn from(it: Enum) -> TypableDef {
624 TypableDef::AdtDef(AdtDef::Enum(it))
625 }
626}
627
628impl From<Union> for TypableDef {
629 fn from(it: Union) -> TypableDef {
630 TypableDef::AdtDef(AdtDef::Union(it))
631 }
632}
633 623
634impl From<ModuleDef> for Option<TypableDef> { 624impl From<ModuleDef> for Option<TypableDef> {
635 fn from(def: ModuleDef) -> Option<TypableDef> { 625 fn from(def: ModuleDef) -> Option<TypableDef> {