From 1b6f95e8853242e1cb5bef71080f151a93d9624b Mon Sep 17 00:00:00 2001 From: David Richey Date: Thu, 23 Jan 2025 17:36:45 -0600 Subject: [PATCH] Check cfg when collecting macro defs --- crates/hir-def/src/body/lower.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs index 1327bb3ab5..16c7b5ca00 100644 --- a/crates/hir-def/src/body/lower.rs +++ b/crates/hir-def/src/body/lower.rs @@ -1381,6 +1381,9 @@ impl ExprCollector<'_> { } } ast::Stmt::Item(ast::Item::MacroDef(macro_)) => { + if self.check_cfg(¯o_).is_none() { + return; + } let Some(name) = macro_.name() else { statements.push(Statement::Item(Item::Other)); return; @@ -1390,6 +1393,9 @@ impl ExprCollector<'_> { self.collect_macro_def(statements, macro_id); } ast::Stmt::Item(ast::Item::MacroRules(macro_)) => { + if self.check_cfg(¯o_).is_none() { + return; + } let Some(name) = macro_.name() else { statements.push(Statement::Item(Item::Other)); return;