resolve: Adjust hygienic_lexical_parent to account for enum and trait modules
This commit is contained in:
parent
0d084670d7
commit
56f635304b
2 changed files with 15 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
14
src/test/ui/resolve/block-with-trait-parent.rs
Normal file
14
src/test/ui/resolve/block-with-trait-parent.rs
Normal 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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue