-
Notifications
You must be signed in to change notification settings - Fork 889
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
[unstable option] trailing_comma #3379
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi, is there any reason why this feature is still considered unstable ? |
I just tried using this feature and it adds trailing commas to function argument lists at the call site.
It also adds trailing commas to match de-structuring even when there's no possibility of more bindings, like:
Adding commas in these instances seems way too broad. Is this intended? What I'd expect when reaching for a feature like this is that a comma should be added to every instance of a "variable size" list where it would be expected that new items can be added without modifying the type (unless it's a type declaration itself) or functions (unless it's a function declaration) involved.
|
@dcow - You didn't specify, but I'm going to assume you are using the You're also free to open a request for an additional variant if you'd like to try to codify the heuristics, though I'll go ahead and note upfront that's not something we'd be able to allocate any of our bandwidth to working on, and would be reliant upon the community to implement. However, I'm not really sure I follow the logic of how a function signature differs from a call site of said function in this context. One of the most common, but not exclusive, reasons people like utilizing trailing commas is to avoid extra diff noise in version control when something changes particularly in multiline cases, regardless of whether that's an additional parameter in a function (which impacts both the sig and call sites), new members in tuples or structs, variants, etc.. That's why the default value is |
hi, may I know when this will be stabilised? just asking. |
|
I'm getting the same behavior as @dcow with the default "Vertical" setting when calling macros. For example I see this let message = format!(
"file is using {} by default",
"LF",
); is formatted to: let message = format!("file is using {} by default", "LF",); Something like: let message = my_format(
"file is using ",
"LF by default",
); formats correctly to: let message = my_format("file is using ", "LF by default"); Not sure if this is a bug or another settings I'm missing? |
Just found this relevant comment: #4956 (comment). |
You beat me to it @externl 😄 but yes macro calls are an entirely different story, and it's intentional that rustfmt isn't stripping user-added commas in those cases for reasons detailed in some of those (transitively) linked issues |
Tracking issue for unstable option: trailing_comma
The text was updated successfully, but these errors were encountered: