Skip to content

Commit 56f6353

Browse files
committed
resolve: Adjust hygienic_lexical_parent to account for enum and trait modules
1 parent 0d08467 commit 56f6353

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,7 @@ impl<'a> Resolver<'a> {
16441644
}
16451645

16461646
if let ModuleKind::Block(..) = module.kind {
1647-
return Some(module.parent.unwrap());
1647+
return Some(module.parent.unwrap().nearest_item_scope());
16481648
}
16491649

16501650
None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
3+
trait Trait {
4+
fn method(&self) {
5+
// Items inside a block turn it into a module internally.
6+
struct S;
7+
impl Trait for S {}
8+
9+
// OK, `Trait` is in scope here from method resolution point of view.
10+
S.method();
11+
}
12+
}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)