-
Notifications
You must be signed in to change notification settings - Fork 926
Do not add a space after metavariable colon #2549
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
Do not add a space after metavariable colon #2549
Conversation
77cfea0
to
cf53ffc
Compare
I have thoughts! I think that changing the default is probably right if we don't do anything fancier. However, I think having options for spaces around colons is not the right approach since I think it mostly comes down to which macro we are formatting rather than user preference (i.e., I can imagine the same user wanting to use different formatting on different macros). We could try to identify |
cf53ffc
to
ccec777
Compare
@nrc Thank you for your review! I am convinced that having config options does not do much. I have update this PR so that it only changes the default behavior to not to add a space after colon. |
Thanks! I've merged the PR, though I worry a little bit about churn for users, if we do try and identify the uses of So I think we must decide now, do we:
|
I prefer to keep the current formatting as a stable way to format macro arguments:
E.g. macro_rules! foo {
($a:ident : $b:ty, bar: $c:ty) => {};
} |
Also we need to get rid of |
Why |
This PR adds two config options
space_after_colon_macro_def
andspace_before_colon_macro_def
which control spaces around a colon of metavariable definitions in macro def.Also this PR changes the default format to not to put a space after a colon. I think that the formatting without a space is more popular in the wild, and incurs less conflicts with users.
Alternatively we could decide whether we should add a space or not based on what kind of separator is used in the definition: if arguments are separated by
,
, then we add a space after each colon, but if weird separators, like=>
,:
or even just a space, are used, then we do not add a space. However this seems too complex and error-prone, so I would rather keep the rule simple and consistent.@nrc Do you have any thoughts on this?
Do we need two options? I think that we do not need to add
space_before_colon_macro_def
, I just added it for consistency with other options.