diff options
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 7 |
3 files changed, 6 insertions, 12 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 7eba0b233..5f480c304 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -474,13 +474,6 @@ impl EnumVariant { | |||
474 | } | 474 | } |
475 | } | 475 | } |
476 | 476 | ||
477 | impl HasVisibility for EnumVariant { | ||
478 | fn visibility(&self, db: &dyn HirDatabase) -> Visibility { | ||
479 | let visibility = &db.enum_data(self.parent.id).visibility; | ||
480 | visibility.resolve(db.upcast(), &self.parent.id.resolver(db.upcast())) | ||
481 | } | ||
482 | } | ||
483 | |||
484 | /// A Data Type | 477 | /// A Data Type |
485 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 478 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
486 | pub enum Adt { | 479 | pub enum Adt { |
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 0fda4d6c9..2bc34d449 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -33,7 +33,6 @@ pub struct StructData { | |||
33 | #[derive(Debug, Clone, PartialEq, Eq)] | 33 | #[derive(Debug, Clone, PartialEq, Eq)] |
34 | pub struct EnumData { | 34 | pub struct EnumData { |
35 | pub name: Name, | 35 | pub name: Name, |
36 | pub visibility: RawVisibility, | ||
37 | pub variants: Arena<EnumVariantData>, | 36 | pub variants: Arena<EnumVariantData>, |
38 | } | 37 | } |
39 | 38 | ||
@@ -92,8 +91,7 @@ impl EnumData { | |||
92 | let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); | 91 | let name = src.value.name().map_or_else(Name::missing, |n| n.as_name()); |
93 | let mut trace = Trace::new_for_arena(); | 92 | let mut trace = Trace::new_for_arena(); |
94 | lower_enum(db, &mut trace, &src, e.lookup(db).container.module(db)); | 93 | lower_enum(db, &mut trace, &src, e.lookup(db).container.module(db)); |
95 | let visibility = RawVisibility::from_ast(db, src.with_value(src.value.visibility())); | 94 | Arc::new(EnumData { name, variants: trace.into_arena() }) |
96 | Arc::new(EnumData { name, visibility, variants: trace.into_arena() }) | ||
97 | } | 95 | } |
98 | 96 | ||
99 | pub fn variant(&self, name: &Name) -> Option<LocalEnumVariantId> { | 97 | pub fn variant(&self, name: &Name) -> Option<LocalEnumVariantId> { |
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 2e2850efb..f990e3bb9 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -6,7 +6,7 @@ | |||
6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). | 6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). |
7 | 7 | ||
8 | use hir::{ | 8 | use hir::{ |
9 | Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, | 9 | Adt, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, |
10 | Semantics, TypeParam, Visibility, | 10 | Semantics, TypeParam, Visibility, |
11 | }; | 11 | }; |
12 | use ra_prof::profile; | 12 | use ra_prof::profile; |
@@ -48,7 +48,10 @@ impl Definition { | |||
48 | Definition::Macro(_) => None, | 48 | Definition::Macro(_) => None, |
49 | Definition::Field(sf) => Some(sf.visibility(db)), | 49 | Definition::Field(sf) => Some(sf.visibility(db)), |
50 | Definition::ModuleDef(def) => match def { | 50 | Definition::ModuleDef(def) => match def { |
51 | ModuleDef::EnumVariant(id) => Some(id.visibility(db)), | 51 | ModuleDef::EnumVariant(id) => { |
52 | let parent = id.parent_enum(db); | ||
53 | module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent))) | ||
54 | } | ||
52 | _ => module?.visibility_of(db, def), | 55 | _ => module?.visibility_of(db, def), |
53 | }, | 56 | }, |
54 | Definition::SelfType(_) => None, | 57 | Definition::SelfType(_) => None, |