-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: Fix associated item visibility in block-local impls #14176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { .. }) { | ||
Comment on lines
+495
to
+497
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a simpler way to check whether a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, then I think this is the appropriate way |
||
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; | ||
|
Uh oh!
There was an error while loading. Please reload this page.