rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

[unstable option] format_macro_matchers

Open scampi opened this issue 6 years ago • 1 comments
trafficstars

Tracking issue for unstable option: format_macro_matchers

scampi avatar Feb 13 '19 22:02 scampi

There are a number of cases where format_macro_matchers adds spaces where Rust syntax would not normally have spaces. For instance:

-    ($cg:ident.$field:ident) => {
+    ($cg:ident. $field:ident) => {

Rust code would normally have ident.ident with no spaces.

I think this option should determine whether to include spaces around a given token based on whether that token would normally have spaces in Rust code.

joshtriplett avatar Aug 31 '22 13:08 joshtriplett

@joshtriplett @scampi I recently opened a PR to fix the opposite issue: #5573, where it was removing a space that should be there:

 macro_rules! test_macro {
-    ($child:expr, Module) => {
+    ($child:expr,Module) => {
         let x = 11;
     };
 }

If everyone is in agreance that . shouldn't ever be followed by a space, I can take a pass at fixing it, while all the code is still fresh in my head! : v)

Personally, I don't think there's ever a reason for . to be followed by a space in 'normal' Rust, so I agree, seems like some dubious formatting to me...

InsertCreativityHere avatar Nov 01 '22 17:11 InsertCreativityHere

@InsertCreativityHere I don't think there are any circumstances where . should have spaces around it, no. Thank you!

joshtriplett avatar Nov 05 '22 15:11 joshtriplett