-
Notifications
You must be signed in to change notification settings - Fork 925
Unintuitive use_small_heuristics
#2636
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
Comments
'small' is deliberately set to be very small because we believe that the readability benefit of using more vertical space usually outweighs any benefit of keeping things on one line. For example, for struct literals, the use case for small is something like Because the small heuristic affects quite a few variables, adding sensitivity options is complex. I do intend to do it, but not in the near future (at least not before a 1.0 release). |
OK thanks! A 1.0 release is more important than this, indeed :) |
I tried to figure out the status of this problem, and as far as I understood:
I didn't find any plans regarding improving the heuristics though, and I think that trying to incrementally define "simple" for the specific obvious cases (such as the |
One issue is that we have a backwards compatibility guarantee and changing the heuristics would break that. So either this would have to be opt-in and/or it would need a 2.0 release. That means the Rustfmt team should absolutely be sure that it is worth working on and plan out exactly when they want to do that. I think we probably could do better than the existing heuristics, and it would be good to do so. So It think it is worth experimenting with better heuristics. However, I also think there are quite a few other things which ought to be higher priority. |
The documentation states “Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'.”
So my definition of “small” here is obviously subjective.
Anyway, I'd have expected
rustfmt 0.4.2-nightly (dd807e2 2018-04-18)
to have put the following on a single line:Then maybe my definition of “small line” is not the same as the one of other people, so maybe an option for tweaking the “sensitivity” of the smallness heuristic could help here?
The text was updated successfully, but these errors were encountered: