Skip to content

Commit 69a8e50

Browse files
Fix input censoring for attr macros when the input contains a key = value attr
It caused the attribute macro to not be removed, causing it to be expanded again and again. I don't know how to test this, as it's hard to test that the recursion limit was reached.
1 parent f7101da commit 69a8e50

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/hir-expand/src/cfg_process.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ fn macro_input_callback(
9595
{
9696
attrs_idx += 1;
9797
}
98-
} else if let Some(has_attrs) = ast::AnyHasAttrs::cast(node.clone()) {
98+
} else if !in_attr && let Some(has_attrs) = ast::AnyHasAttrs::cast(node.clone()) {
99+
// Attributes of the form `key = value` have `ast::Expr` in them, which returns `Some` for
100+
// `AnyHasAttrs::cast()`, so we also need to check `in_attr`.
101+
99102
if has_inner_attrs_owner {
100103
has_inner_attrs_owner = false;
101104
return (true, Vec::new());

0 commit comments

Comments
 (0)