Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ fn rewrite_macro_inner(
}
};

if !arg_vec.is_empty() && arg_vec.iter().all(MacroArg::is_item) {
let has_item = arg_vec.iter().any(MacroArg::is_item);
if has_item && arg_vec.iter().all(MacroArg::is_item) {
return rewrite_macro_with_items(
context,
&arg_vec,
Expand All @@ -268,6 +269,9 @@ fn rewrite_macro_inner(
mac.span(),
);
}
if has_item {
return return_macro_parse_failure_fallback(context, shape.indent, position, mac.span());
}

match style {
Delimiter::Parenthesis => {
Expand Down
13 changes: 13 additions & 0 deletions tests/source/issue-6629.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
macro_rules! reproduce {
(type Fail = $ty:ty; arr = $($arr:expr),+) => {
( vec![$($arr),+] )
};
( $expr:expr, $($arr:item),+) => {
1
};
}

fn main() {
reproduce!(type Fail = char; arr = 1);
reproduce!(23, type Fail = char;, type Fail = char;);
}
13 changes: 13 additions & 0 deletions tests/target/issue-6629.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
macro_rules! reproduce {
(type Fail = $ty:ty; arr = $($arr:expr),+) => {
( vec![$($arr),+] )
};
( $expr:expr, $($arr:item),+) => {
1
};
}

fn main() {
reproduce!(type Fail = char; arr = 1);
reproduce!(23, type Fail = char;, type Fail = char;);
}
Loading