internal: get rid of a call to slow O(N) visibility_of function

Instead of inferring module's declared visibility by looking at the
scope of its parent, let's just remeber the declared visibility in the
DefMap.
This commit is contained in:
Aleksey Kladov 2021-07-12 21:13:43 +03:00
parent c8d19fedb8
commit 6f269708e8
4 changed files with 29 additions and 13 deletions

View file

@ -45,11 +45,7 @@ impl Definition {
match self {
Definition::Field(sf) => Some(sf.visibility(db)),
Definition::ModuleDef(def) => match def {
ModuleDef::Module(it) => {
// FIXME: should work like other cases here.
let parent = it.parent(db)?;
parent.visibility_of(db, def)
}
ModuleDef::Module(it) => Some(it.visibility(db)),
ModuleDef::Function(it) => Some(it.visibility(db)),
ModuleDef::Adt(it) => Some(it.visibility(db)),
ModuleDef::Const(it) => Some(it.visibility(db)),