mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 17:58:16 +00:00
Merge #7518
7518: Use the right `DefMap` when looking up modules r=jonas-schievink a=jonas-schievink Fixes the bugs encountered in https://github.com/rust-analyzer/rust-analyzer/pull/7506#issuecomment-771417467 bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
8720f7f146
3 changed files with 20 additions and 2 deletions
|
@ -258,6 +258,10 @@ impl DefMap {
|
|||
self.krate
|
||||
}
|
||||
|
||||
pub(crate) fn block_id(&self) -> Option<BlockId> {
|
||||
self.block.as_ref().map(|block| block.block)
|
||||
}
|
||||
|
||||
pub(crate) fn prelude(&self) -> Option<ModuleId> {
|
||||
self.prelude
|
||||
}
|
||||
|
|
|
@ -592,7 +592,13 @@ impl DefCollector<'_> {
|
|||
// glob import from same crate => we do an initial
|
||||
// import, and then need to propagate any further
|
||||
// additions
|
||||
let scope = &self.def_map[m.local_id].scope;
|
||||
let def_map;
|
||||
let scope = if m.block == self.def_map.block_id() {
|
||||
&self.def_map[m.local_id].scope
|
||||
} else {
|
||||
def_map = m.def_map(self.db);
|
||||
&def_map[m.local_id].scope
|
||||
};
|
||||
|
||||
// Module scoped macros is included
|
||||
let items = scope
|
||||
|
|
|
@ -271,8 +271,16 @@ impl DefMap {
|
|||
);
|
||||
}
|
||||
|
||||
let def_map;
|
||||
let module_data = if module.block == self.block_id() {
|
||||
&self[module.local_id]
|
||||
} else {
|
||||
def_map = module.def_map(db);
|
||||
&def_map[module.local_id]
|
||||
};
|
||||
|
||||
// Since it is a qualified path here, it should not contains legacy macros
|
||||
self[module.local_id].scope.get(&segment)
|
||||
module_data.scope.get(&segment)
|
||||
}
|
||||
ModuleDefId::AdtId(AdtId::EnumId(e)) => {
|
||||
// enum variant
|
||||
|
|
Loading…
Reference in a new issue