Repository navigation
Struct fields: remove unnecessary parens #7161
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // rustfmt-style_edition: 2027 | ||
|
|
||
| struct F { | ||
| f: ((u32)), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are parens removed if there are comments?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably also add a test case with a lot more parens. Something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
only parens without any leading/trailing comments, e.g. struct S {
f: (/* comment */((u8))),
}Would be re-written to: struct S {
f: ((u8)),
}Notably:
So I think this shouldn't be a standalone change, and I'll need to just combine it with my change to not remove those comments (I created this PR to try and split that work into a few smaller changes) |
||
| } | ||
|
|
||
| struct F(((u32))); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // rustfmt-style_edition: 2027 | ||
|
|
||
| struct F { | ||
| f: (u32), | ||
| } | ||
|
|
||
| struct F((u32)); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if this doesn't already it should probably also be configured using
remove_nested_parens. We'll want to add a test case to show that parens aren't removed whenremove_nested_parens=false. It'strueby default so it's not necessary in this case, but might be good to be explicit about it.I think we should also add a
style_edition=2024test case to show that parens aren't removed even withremove_nested_parens=trueto highlight the issue we're solving.View changes since the review