-
Notifications
You must be signed in to change notification settings - Fork 901
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
Update width heuristic configuration #4063
Update width heuristic configuration #4063
Conversation
What's the status of this PR? Not having control over line length is my single greatest frustration with rustfmt—would absolutely love to see this merged! Is there anything I can do to help? |
Thanks for the offer @benesch! It's a fairly sizeable change, so really just needs a review from @topecongiro Please also note that this will be part of the rustfmt 2.0 release (which does not yet have a planned date). That means that even once this is merged it will be still be some time before this change would be available for consumption except for folks building rustfmt from source.
Just out of curiosity, Is that frustration specifically with the lack of control/granularity available today between I'm guessing this will most benefit users that like some, but not all, aspects of settings controlled by |
Ah, gotcha.
I'm honestly probably willing to do just that in the meantime.
Yeah, it's entirely the lack of granularity. I've tried setting |
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.
Sorry for the late review. Overall this looks good to me; Just one point, I commented on error handling.
bdce45b
to
6f82ea9
Compare
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.
LGTM, thank you for the updates!
Closes #3710
The diff makes this seem bigger than it actually is, but there's really not all that much in this PR.
In addition to
max_width
, rustfmt has internally used 7 different max width settings for specific code constructs as part of the heuristics for determining whether to use multi-line/vertical formatting. These private settings were set based on the value provided for the public/user-facinguse_small_heuristics
config option. Essentially,use_small_heuristic
was the public facing knob that controlled 7 private options.That's helpful in scenarios where users want a minimal config and want to be able to simply update and manage one "width" config option (
max_width
), but it was problematic for users that wanted to have more granular control over those individual width settings.With this change rustfmt should now be able to support both as all the individual width heuristic config options are now public and available for users to set, but there's also still a global heuristic setting that can be used as well.
In this PR:
use_small_heuristics
towidth_heuristics
and theDefault
variant was renamed toScaled
*_width
config options are all now public and can be set/overriden by users.*_width
options that exceeds the value ofmax_width