resolve: Adjust hygienic_lexical_parent to account for enum and trait modules

This commit is contained in:
Vadim Petrochenkov 2019-09-07 17:33:50 +03:00
parent 0d084670d7
commit 56f635304b
2 changed files with 15 additions and 1 deletions

View file

@ -1644,7 +1644,7 @@ impl<'a> Resolver<'a> {
}
if let ModuleKind::Block(..) = module.kind {
return Some(module.parent.unwrap());
return Some(module.parent.unwrap().nearest_item_scope());
}
None

View file

@ -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() {}