Repository navigation
Conversation
|
So #6651 changed default behavior that we didn't catch? |
Darn, at the time it didn't occur to me that |
My understanding is that yes we do, 1.100 is current beta, 9 days out to next stable. Let me prep a revert series. We'd need to sync the revert series too. |
|
I don’t think it changes default formatting. By default no widths are explicitly set, so they all come from small heuristics, which are based on With someone setting explicit width properties (e.g.
|
Ah right, my bad, it would not be stable default formatting, it would need stable options.
@csmulhern no need to be; it just didn't occur to me at the time. The fix is still very appreciated! |
Ah cool, that sounds good. To be safe, I think we should still land the revert on beta, then reland #6651 + #7152 + this change after the release cycling just to give the combined change some more time to bake across two release cycles. (A fix-forward with this PR is somewhat appealing but I tend to want to be very conservative with backports, since fix-forwards can introduce new bugs and we'd not have enough time to fix any of those in the 1.100 beta.) |
|
Yup, same thoughts here. I'm all for being conservative given the low margin for error. |
This comment has been minimized.
This comment has been minimized.
[beta] Revert "Fixes adjustment of `max_width` within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152) rust-lang/rust side beta-backport of rust-lang/rustfmt#7222. Part of rust-lang/rustfmt#7223. Closes rust-lang/rustfmt#7223. See rust-lang/rustfmt#7221 (comment). This PR reverts both: 1. rust-lang/rustfmt#6651 (partially; I kept the baseline test commit but not the actual formatting change commit), and 2. rust-lang/rustfmt#7152 (follow-up fix) r? @ytmimi
[beta] Revert "Fixes adjustment of `max_width` within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152) rust-lang/rust side beta-backport of rust-lang/rustfmt#7222. Part of rust-lang/rustfmt#7223. Closes rust-lang/rustfmt#7223. See rust-lang/rustfmt#7221 (comment). This PR reverts both: 1. rust-lang/rustfmt#6651 (partially; I kept the baseline test commit but not the actual formatting change commit), and 2. rust-lang/rustfmt#7152 (follow-up fix) r? @ytmimi
[beta] Revert "Fixes adjustment of `max_width` within macros" (rust-lang/rustfmt#6651) and follow-up (rust-lang/rustfmt#7152) rust-lang/rust side beta-backport of rust-lang/rustfmt#7222. Part of rust-lang/rustfmt#7223. Closes rust-lang/rustfmt#7223. See rust-lang/rustfmt#7221 (comment). This PR reverts both: 1. rust-lang/rustfmt#6651 (partially; I kept the baseline test commit but not the actual formatting change commit), and 2. rust-lang/rustfmt#7152 (follow-up fix) r? @ytmimi
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
There was a problem hiding this comment.
Thanks. AFAICT this is correct and only removes the warning but does not modify stable default formatting or stable options formatting.
Minor nits re. comments and test coverage.
@rustbot author
| () => { | ||
| m!(aaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, cccccccccccccccc, dddddddddddddddd); | ||
| }; | ||
| } |
There was a problem hiding this comment.
NB: I was looking at the logic here a bit more closely. I know obviously that the ui tests here won't demonstrate "ah the warning went away" (that's #6933), which is the point for this PR.
So my understanding is that, there's 3 cases we need to consider:
- Explicit width never set, i.e. default config
- Explicit width configured, but:
- (A) > recomputed (reduced) max width, so it has to be capped to recomputed max width.
- (B) <= recomputed (reduced) max width, so fits in recomputed max width.
Here:
- (1) unaffected.
- (2A) is stable option behavior (though it has a warning à la Cannot set granular width configuration settings to 100% if
max_width = 100#5404), and we're not changing it modulo removing the cap warning. - (2B) is stable option behavior, and unchanged by this PR.
There was a problem hiding this comment.
Yes, that's right. The only change from this PR should now be the warning.
-
default.rscovers this. -
Covered by
custom_width.rsandchain_width.rs:-
A.
custom_width.rssetsfn_call_widthto 76, which is capped to 74 inside the macro.longfits within 74, so it stays on one line. The original Fixes adjustment of max_width within macros #6651 cut the width to 68 and wrapped it.too_longis overmax_width, so it wraps regardless. -
B.
chain_width.rswas the piece missing in the original PR that covers this. It setschain_widthto 72 and uses a 70 character expression, so the expression stays on one line inside and outside the macro (unlike Fixes adjustment of max_width within macros #6651 which reducedchain_widthand wrapped the macro version).
-
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@jieyouxu I haven't had a chance to look at this one yet, but I'd also like to review this before merging. |
This is an update to #6651. Since updating to the rustfmt beta that includes that change, I noticed that explicitly set widths that are involved in small heuristics can now cause formatting differences between the same code inside and outside of a macro.
The original sin that makes this space challenging is how macros are formatted by forking the config and formatting the macro body as if it had zero indent + reduced max width. Because of this, #6651 reduced the width of all the other explicit width properties that are involved in small heuristics. However, these properties are applied independent of indent. This PR fixes this inconsistency for explicitly set widths by not modifying the values beyond capping them based on
max_width. Note: there are still likely other ways that macro bodies format inconsistently, due to the original sin.The tests have been updated to account for this nuance.
As a quick example, here is code that formats inconsistently today:
The code formats consistently with this change.