Remove HasVisibility implementation

This commit is contained in:
Fedor Sakharov 2020-05-07 16:30:20 +03:00
parent bd9f1f7eb7
commit 210f0cbd27
No known key found for this signature in database
GPG Key ID: 93D436E666BF0FEE
3 changed files with 6 additions and 12 deletions

View File

@ -474,13 +474,6 @@ impl EnumVariant {
}
}
impl HasVisibility for EnumVariant {
fn visibility(&self, db: &dyn HirDatabase) -> Visibility {
let visibility = &db.enum_data(self.parent.id).visibility;
visibility.resolve(db.upcast(), &self.parent.id.resolver(db.upcast()))
}
}
/// A Data Type
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Adt {

View File

@ -33,7 +33,6 @@ pub struct StructData {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EnumData {
pub name: Name,
pub visibility: RawVisibility,
pub variants: Arena<EnumVariantData>,
}
@ -92,8 +91,7 @@ impl EnumData {
let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
let mut trace = Trace::new_for_arena();
lower_enum(db, &mut trace, &src, e.lookup(db).container.module(db));
let visibility = RawVisibility::from_ast(db, src.with_value(src.value.visibility()));
Arc::new(EnumData { name, visibility, variants: trace.into_arena() })
Arc::new(EnumData { name, variants: trace.into_arena() })
}
pub fn variant(&self, name: &Name) -> Option<LocalEnumVariantId> {

View File

@ -6,7 +6,7 @@
// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06).
use hir::{
Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution,
Adt, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution,
Semantics, TypeParam, Visibility,
};
use ra_prof::profile;
@ -48,7 +48,10 @@ impl Definition {
Definition::Macro(_) => None,
Definition::Field(sf) => Some(sf.visibility(db)),
Definition::ModuleDef(def) => match def {
ModuleDef::EnumVariant(id) => Some(id.visibility(db)),
ModuleDef::EnumVariant(id) => {
let parent = id.parent_enum(db);
module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent)))
}
_ => module?.visibility_of(db, def),
},
Definition::SelfType(_) => None,