mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Merge #4421
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:
commit
05399250d4
3 changed files with 47 additions and 10 deletions
|
@ -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::{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue