-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metavariables in macro def #121
Comments
Metavariables were discussed back in the day in the style team - we agreed on |
Repeating what I said in rust-lang/rustfmt#2534 (comment), macros should be formatted like normal code, i.e. with space in |
I can't find any discussion of macros in this repo and I don't recall coming to the conclusion in #121 (comment), however, it is perfectly possible that we did - it was a long time ago. In the current guide, we don't have any discussion on macro defintions, and since they can be arbitrary tokens I'm not sure we even can give good guidance. I do agree with @petrochenkov that we should make macros look like functions (since they are very similar in the common case). However, the no space pattern is common in the ecosystem and certainly looks better when |
There are a few interesting differences:
It's important to note that in macros commas are tokens, too. Consider this:
I find it a little difficult to skim through this token list and visually figure out what is a token and what is a type. The following formatting is easier to follow for me:
Finally, separators are visually lightweight so I'm okay with gluing the comma to the first token:
Lately I've been working with macros a lot and found that I read function signatures and macro patterns differently:
|
Recently rustfmt started to format macro def.
Should rustfmt add a space after
:
of metavariables? Adding a space is consistent with other items like function or type declaration. However majority of the code in the wild seems to use the no-space style.Also what should we do when metavariables are separated by separators other than
,
, especially by:
?The text was updated successfully, but these errors were encountered: