mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
internal: remove one usage of a slow method
This commit is contained in:
parent
5fee2bef19
commit
8e0630e728
3 changed files with 20 additions and 4 deletions
|
@ -436,6 +436,7 @@ impl Module {
|
|||
module_data.visibility
|
||||
}
|
||||
|
||||
/// XXX: this O(N) rather O(1) method, avoid using it if you can.
|
||||
pub fn visibility_of(self, db: &dyn HirDatabase, def: &ModuleDef) -> Option<Visibility> {
|
||||
let def_map = self.id.def_map(db.upcast());
|
||||
let module_data = &def_map[self.id.local_id];
|
||||
|
@ -841,6 +842,13 @@ impl Variant {
|
|||
}
|
||||
}
|
||||
|
||||
/// Variants inherit visibility from the parent enum.
|
||||
impl HasVisibility for Variant {
|
||||
fn visibility(&self, db: &dyn HirDatabase) -> Visibility {
|
||||
self.parent_enum(db).visibility(db)
|
||||
}
|
||||
}
|
||||
|
||||
/// A Data Type
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum Adt {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue