mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Adjust block-local impl item visibility rendering
This commit is contained in:
parent
83e24fec98
commit
d4166234ef
3 changed files with 216 additions and 9 deletions
|
@ -46,7 +46,7 @@ use hir_def::{
|
|||
item_tree::ItemTreeNode,
|
||||
lang_item::{LangItem, LangItemTarget},
|
||||
layout::{Layout, LayoutError, ReprOptions},
|
||||
nameres::{self, diagnostics::DefDiagnostic},
|
||||
nameres::{self, diagnostics::DefDiagnostic, ModuleOrigin},
|
||||
per_ns::PerNs,
|
||||
resolver::{HasResolver, Resolver},
|
||||
src::HasSource as _,
|
||||
|
@ -488,6 +488,20 @@ impl Module {
|
|||
Some(Module { id: def_map.module_id(parent_id) })
|
||||
}
|
||||
|
||||
/// Finds nearest non-block ancestor `Module` (`self` included).
|
||||
fn nearest_non_block_module(self, db: &dyn HirDatabase) -> Module {
|
||||
let mut id = self.id;
|
||||
loop {
|
||||
let def_map = id.def_map(db.upcast());
|
||||
let origin = def_map[id.local_id].origin;
|
||||
if matches!(origin, ModuleOrigin::BlockExpr { .. }) {
|
||||
id = id.containing_module(db.upcast()).expect("block without parent module")
|
||||
} else {
|
||||
return Module { id };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path_to_root(self, db: &dyn HirDatabase) -> Vec<Module> {
|
||||
let mut res = vec![self];
|
||||
let mut curr = self;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue