aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-22 19:26:30 +0100
committerGitHub <[email protected]>2021-06-22 19:26:30 +0100
commit9b29573a4bfcecfcd3c48ada589f6129323a559c (patch)
tree61b75baa49f6b88c24fbda5f44ac734fed1f7d98 /crates/ide_db
parent9239943b84ec2bd687c4c80d2c3a0df4f8caf31c (diff)
parent7be2d2f008595114e19aad0aa0608ddedfe3edf7 (diff)
Merge #9379
9379: internal: remove one more accidentally quadratic code-path r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/defs.rs28
1 files changed, 22 insertions, 6 deletions
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index a54f2c323..fddd1fc2d 100644
--- a/crates/ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
@@ -43,13 +43,29 @@ impl Definition {
43 43
44 pub fn visibility(&self, db: &RootDatabase) -> Option<Visibility> { 44 pub fn visibility(&self, db: &RootDatabase) -> Option<Visibility> {
45 match self { 45 match self {
46 Definition::Macro(_) => None,
47 Definition::Field(sf) => Some(sf.visibility(db)), 46 Definition::Field(sf) => Some(sf.visibility(db)),
48 Definition::ModuleDef(def) => def.definition_visibility(db), 47 Definition::ModuleDef(def) => match def {
49 Definition::SelfType(_) => None, 48 ModuleDef::Module(it) => {
50 Definition::Local(_) => None, 49 // FIXME: should work like other cases here.
51 Definition::GenericParam(_) => None, 50 let parent = it.parent(db)?;
52 Definition::Label(_) => None, 51 parent.visibility_of(db, def)
52 }
53 ModuleDef::Function(it) => Some(it.visibility(db)),
54 ModuleDef::Adt(it) => Some(it.visibility(db)),
55 ModuleDef::Const(it) => Some(it.visibility(db)),
56 ModuleDef::Static(it) => Some(it.visibility(db)),
57 ModuleDef::Trait(it) => Some(it.visibility(db)),
58 ModuleDef::TypeAlias(it) => Some(it.visibility(db)),
59 // NB: Variants don't have their own visibility, and just inherit
60 // one from the parent. Not sure if that's the right thing to do.
61 ModuleDef::Variant(it) => Some(it.parent_enum(db).visibility(db)),
62 ModuleDef::BuiltinType(_) => None,
63 },
64 Definition::Macro(_)
65 | Definition::SelfType(_)
66 | Definition::Local(_)
67 | Definition::GenericParam(_)
68 | Definition::Label(_) => None,
53 } 69 }
54 } 70 }
55 71