From 6a3f2ce76ca06c5541b3bdd8c626abedbc812685 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 1 Apr 2021 03:45:21 +0800 Subject: Fix block inner item defined in macro --- crates/hir_def/src/item_tree/lower.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/hir_def/src') diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 8d3862811..124dcc866 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -174,6 +174,12 @@ impl Ctx { let forced_vis = self.forced_visibility.take(); let mut block_stack = Vec::new(); + + // if container itself is block, add it to the stack + if let Some(block) = ast::BlockExpr::cast(container.clone()) { + block_stack.push(self.source_ast_id_map.ast_id(&block)); + } + for event in container.preorder().skip(1) { match event { WalkEvent::Enter(node) => { -- cgit v1.2.3