Skip to content

Commit

Permalink
resolve: Adjust hygienic_lexical_parent to account for enum and tra…
Browse files Browse the repository at this point in the history
…it modules
  • Loading branch information
petrochenkov committed Sep 7, 2019
1 parent 0d08467 commit 56f6353
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/resolve/block-with-trait-parent.rs
@@ -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() {}

0 comments on commit 56f6353

Please sign in to comment.