From de6ec2ecba291702871ab2afe323e9527e15fdf1 Mon Sep 17 00:00:00 2001 From: Austin Henriksen Date: Tue, 25 Oct 2022 12:04:38 -0400 Subject: [PATCH 1/2] Always place spaces after commas in macro match arms. --- src/macros.rs | 1 - tests/target/macro_rules.rs | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 6e114c76f26..d08ad6d97c1 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1085,7 +1085,6 @@ fn next_space(tok: &TokenKind) -> SpaceState { | TokenKind::BinOp(BinOpToken::And) | TokenKind::Tilde | TokenKind::At - | TokenKind::Comma | TokenKind::Dot | TokenKind::DotDot | TokenKind::DotDotDot diff --git a/tests/target/macro_rules.rs b/tests/target/macro_rules.rs index 97444aef404..5e7512470dc 100644 --- a/tests/target/macro_rules.rs +++ b/tests/target/macro_rules.rs @@ -43,7 +43,7 @@ macro_rules! impl_a_method { $body } macro_rules! $n { - ($va: expr,$vb: expr) => { + ($va: expr, $vb: expr) => { $n($va, $vb) }; } @@ -55,7 +55,7 @@ macro_rules! impl_a_method { $body } macro_rules! $n { - ($va: expr,$vb: expr,$vc: expr) => { + ($va: expr, $vb: expr, $vc: expr) => { $n($va, $vb, $vc) }; } @@ -68,7 +68,7 @@ macro_rules! impl_a_method { $body } macro_rules! $n { - ($va: expr,$vb: expr,$vc: expr,$vd: expr) => { + ($va: expr, $vb: expr, $vc: expr, $vd: expr) => { $n($va, $vb, $vc, $vd) }; } From bc64185a25ba4e96d644911d361ab112f9b33d1e Mon Sep 17 00:00:00 2001 From: Austin Henriksen Date: Tue, 15 Nov 2022 16:24:09 -0500 Subject: [PATCH 2/2] Added test case for spaces after trailing commas in macro match arms. --- tests/source/macro_rules.rs | 1 + tests/target/macro_rules.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/source/macro_rules.rs b/tests/source/macro_rules.rs index 5aaca0c83fa..f480385ae2f 100644 --- a/tests/source/macro_rules.rs +++ b/tests/source/macro_rules.rs @@ -4,6 +4,7 @@ macro_rules! m { () => (); ( $ x : ident ) => (); ( $ m1 : ident , $ m2 : ident , $ x : ident ) => (); + ( $ m1 : ident , $ m2 : ident , $ x : ident , ) => (); ( $($beginning:ident),*;$middle:ident;$($end:ident),* ) => (); ( $($beginning: ident),*; $middle: ident; $($end: ident),*; $($beginning: ident),*; $middle: ident; $($end: ident),* ) => {}; ( $ name : ident ( $ ( $ dol : tt $ var : ident ) * ) $ ( $ body : tt ) * ) => (); diff --git a/tests/target/macro_rules.rs b/tests/target/macro_rules.rs index 5e7512470dc..b19813203d9 100644 --- a/tests/target/macro_rules.rs +++ b/tests/target/macro_rules.rs @@ -4,6 +4,7 @@ macro_rules! m { () => {}; ($x:ident) => {}; ($m1:ident, $m2:ident, $x:ident) => {}; + ($m1:ident, $m2:ident, $x:ident,) => {}; ($($beginning:ident),*; $middle:ident; $($end:ident),*) => {}; ( $($beginning:ident),*;