diff --git a/src/macros.rs b/src/macros.rs index b2146437f15..de8e0651cd8 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -303,9 +303,9 @@ fn rewrite_macro_inner( if DelimToken::Brace != style { loop { - if let Some(arg) = parse_macro_arg(&mut parser) { + if let Some(arg) = check_keyword(&mut parser) { arg_vec.push(arg); - } else if let Some(arg) = check_keyword(&mut parser) { + } else if let Some(arg) = parse_macro_arg(&mut parser) { arg_vec.push(arg); } else { return return_macro_parse_failure_fallback(context, shape.indent, mac.span); diff --git a/src/overflow.rs b/src/overflow.rs index d8e1d0e2590..fc0cf98ceba 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -122,6 +122,7 @@ impl<'a> OverflowableItem<'a> { pub(crate) fn is_simple(&self) -> bool { match self { OverflowableItem::Expr(expr) => is_simple_expr(expr), + OverflowableItem::MacroArg(MacroArg::Keyword(..)) => true, OverflowableItem::MacroArg(MacroArg::Expr(expr)) => is_simple_expr(expr), OverflowableItem::NestedMetaItem(nested_meta_item) => match nested_meta_item { ast::NestedMetaItem::Literal(..) => true, diff --git a/tests/source/issue-3709.rs b/tests/source/issue-3709.rs new file mode 100644 index 00000000000..73c2a624e52 --- /dev/null +++ b/tests/source/issue-3709.rs @@ -0,0 +1,10 @@ +// rustfmt-edition: 2018 + +macro_rules! token { + ($t:tt) => {}; +} + +fn main() { + token!(dyn); + token!(dyn ); +} diff --git a/tests/target/issue-3709.rs b/tests/target/issue-3709.rs new file mode 100644 index 00000000000..0f3eae048d4 --- /dev/null +++ b/tests/target/issue-3709.rs @@ -0,0 +1,10 @@ +// rustfmt-edition: 2018 + +macro_rules! token { + ($t:tt) => {}; +} + +fn main() { + token!(dyn); + token!(dyn); +}