4421: Find references to a function outside module r=flodiebold a=montekki

Fixes #4188 

Yet again, it looks like although the code in 
da1f316b02/crates/ra_ide_db/src/search.rs (L128-L132)

may be wrong, it is not hit since the `vis` is `None` at this point. The fix is similar to the #4237 case: just add another special case to `Definition::visibility()`.

Co-authored-by: Fedor Sakharov <fedor.sakharov@gmail.com>
This commit is contained in:
bors[bot] 2020-05-11 12:21:08 +00:00 committed by GitHub
commit 05399250d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 10 deletions

View file

@ -148,6 +148,26 @@ impl ModuleDef {
ModuleDef::BuiltinType(_) => None,
}
}
pub fn definition_visibility(&self, db: &dyn HirDatabase) -> Option<Visibility> {
let module = match self {
ModuleDef::Module(it) => it.parent(db)?,
ModuleDef::Function(it) => return Some(it.visibility(db)),
ModuleDef::Adt(it) => it.module(db),
ModuleDef::EnumVariant(it) => {
let parent = it.parent_enum(db);
let module = it.module(db);
return module.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent)));
}
ModuleDef::Const(it) => return Some(it.visibility(db)),
ModuleDef::Static(it) => it.module(db),
ModuleDef::Trait(it) => it.module(db),
ModuleDef::TypeAlias(it) => return Some(it.visibility(db)),
ModuleDef::BuiltinType(_) => return None,
};
module.visibility_of(db, self)
}
}
pub use hir_def::{