Skip to content

Commit a365f73

Browse files
authored
Merge pull request #19014 from darichey/fix-cfg-macro
Check cfg when collecting macro defs
2 parents 7ba18da + 27084a2 commit a365f73

File tree

1 file changed

+6
-0
lines changed
  • src/tools/rust-analyzer/crates/hir-def/src/body

1 file changed

+6
-0
lines changed

src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,9 @@ impl ExprCollector<'_> {
13811381
}
13821382
}
13831383
ast::Stmt::Item(ast::Item::MacroDef(macro_)) => {
1384+
if self.check_cfg(&macro_).is_none() {
1385+
return;
1386+
}
13841387
let Some(name) = macro_.name() else {
13851388
statements.push(Statement::Item(Item::Other));
13861389
return;
@@ -1390,6 +1393,9 @@ impl ExprCollector<'_> {
13901393
self.collect_macro_def(statements, macro_id);
13911394
}
13921395
ast::Stmt::Item(ast::Item::MacroRules(macro_)) => {
1396+
if self.check_cfg(&macro_).is_none() {
1397+
return;
1398+
}
13931399
let Some(name) = macro_.name() else {
13941400
statements.push(Statement::Item(Item::Other));
13951401
return;

0 commit comments

Comments
 (0)