mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
resolve: Adjust hygienic_lexical_parent to account for enum and trait modules
This commit is contained in:
@@ -1644,7 +1644,7 @@ fn hygienic_lexical_parent(&mut self, module: Module<'a>, span: &mut Span)
|
||||
}
|
||||
|
||||
if let ModuleKind::Block(..) = module.kind {
|
||||
return Some(module.parent.unwrap());
|
||||
return Some(module.parent.unwrap().nearest_item_scope());
|
||||
}
|
||||
|
||||
None
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// check-pass
|
||||
|
||||
trait Trait {
|
||||
fn method(&self) {
|
||||
// Items inside a block turn it into a module internally.
|
||||
struct S;
|
||||
impl Trait for S {}
|
||||
|
||||
// OK, `Trait` is in scope here from method resolution point of view.
|
||||
S.method();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user