-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Reserve width for const when formatting inline const blocks
#7065
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,29 @@ | ||
| // rustfmt-style_edition: 2027 | ||
|
|
||
| struct S; | ||
|
|
||
| impl S { | ||
| const fn new(_: &str) -> Self { | ||
| S | ||
| } | ||
|
|
||
| fn go(&self) {} | ||
| } | ||
|
|
||
| fn main() { | ||
| const { | ||
| S::new( | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | ||
| ) | ||
| } | ||
| .go(); | ||
| } | ||
|
|
||
| fn removes_trailing_whitespace() { | ||
| const { | ||
| S::new( | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | ||
| ) | ||
| } | ||
| .go(); | ||
| } | ||
|
Comment on lines
+13
to
+29
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. What's the difference between 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. There's a space after
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. @astral4 thanks for pointing that out. @AsthaMishra the trailing whitespace isn't so obvious. Instead of naming it |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // rustfmt-style_edition: 2027 | ||
|
|
||
| struct S; | ||
|
|
||
| impl S { | ||
| const fn new(_: &str) -> Self { | ||
| S | ||
| } | ||
|
|
||
| fn go(&self) {} | ||
| } | ||
|
|
||
| fn main() { | ||
| const { | ||
| S::new("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") | ||
| } | ||
| .go(); | ||
| } | ||
|
|
||
| fn removes_trailing_whitespace() { | ||
| const { | ||
| S::new("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") | ||
| } | ||
| .go(); | ||
| } |
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.
Thanks for adding the gate. This looks right to me, but I want to confirm something first before moving forward. #7055 mentioned that
unsafeblocks didn't have this problem. I'd like to understand why that's the case. Maybe there's something going on insiderewrite_blockwhere the shape is properly updated?There are also
try,gen, andasyncblocks. Might be good to check that we're handling those correctly too.View changes since the review
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.
if there is
unsafe, we get it in prefix -let prefix = block_prefix(context, block, shape)?;and in functionrewrite_single_line_blockresult contains itbut for const - prefix is empty
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.
try,async, andgenblocks pass their prefix intorewrite_single_line_block, so these works fine