mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Fix: Handle block exprs as modules when finding their parents
This commit is contained in:
parent
28830ff2f1
commit
e09c2a08d7
4 changed files with 46 additions and 7 deletions
|
@ -497,10 +497,9 @@ impl Module {
|
|||
|
||||
/// Finds a parent module.
|
||||
pub fn parent(self, db: &dyn HirDatabase) -> Option<Module> {
|
||||
// FIXME: handle block expressions as modules (their parent is in a different DefMap)
|
||||
let def_map = self.id.def_map(db.upcast());
|
||||
let parent_id = def_map[self.id.local_id].parent?;
|
||||
Some(Module { id: def_map.module_id(parent_id) })
|
||||
let parent_id = def_map.containing_module(self.id.local_id)?;
|
||||
Some(Module { id: parent_id })
|
||||
}
|
||||
|
||||
/// Finds nearest non-block ancestor `Module` (`self` included).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue