Skip to content

Commit

Permalink
fix: remove trailing space with empty dyn macro arg (rust-lang#3737)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright authored and topecongiro committed Aug 11, 2019
1 parent e653ff0 commit ac150d0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions tests/source/issue-3709.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// rustfmt-edition: 2018

macro_rules! token {
($t:tt) => {};
}

fn main() {
token!(dyn);
token!(dyn );
}
10 changes: 10 additions & 0 deletions tests/target/issue-3709.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// rustfmt-edition: 2018

macro_rules! token {
($t:tt) => {};
}

fn main() {
token!(dyn);
token!(dyn);
}

0 comments on commit ac150d0

Please # to comment.