mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Change ids strategy
this is a part of larghish hir refactoring which aims to * replace per-source-root module trees with per crate trees * switch from a monotyped DedId to type-specific ids
This commit is contained in:
parent
cfb085ded8
commit
3ab1519cb2
26 changed files with 365 additions and 430 deletions
|
@ -97,7 +97,17 @@ impl NavigationTarget {
|
|||
}
|
||||
|
||||
// TODO once Def::Item is gone, this should be able to always return a NavigationTarget
|
||||
pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Option<NavigationTarget> {
|
||||
pub(crate) fn from_def(
|
||||
db: &RootDatabase,
|
||||
module_def: hir::ModuleDef,
|
||||
) -> Option<NavigationTarget> {
|
||||
let def = match module_def {
|
||||
hir::ModuleDef::Def(def_id) => def_id.resolve(db),
|
||||
hir::ModuleDef::Module(module) => {
|
||||
return Some(NavigationTarget::from_module(db, module));
|
||||
}
|
||||
};
|
||||
|
||||
let res = match def {
|
||||
Def::Struct(s) => {
|
||||
let (file_id, node) = s.source(db);
|
||||
|
@ -131,7 +141,6 @@ impl NavigationTarget {
|
|||
let (file_id, node) = f.source(db);
|
||||
NavigationTarget::from_named(file_id.original_file(db), &*node)
|
||||
}
|
||||
Def::Module(m) => NavigationTarget::from_module(db, m),
|
||||
Def::Item => return None,
|
||||
};
|
||||
Some(res)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue