-
Notifications
You must be signed in to change notification settings - Fork 900
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
Use versionsort for everything that's auto-reordered by name #3764
Conversation
Thank you for the PR! I appreciate your work and effort to improve rustfmt.
rustfmt has some serious restriction when it comes to changing its default format style (see rust-lang/rust#54504 for the context if you are interested). |
@topecongiro If this is merged with version-gating, do I understand correctly that it will be impossible to opt in to it until rustfmt reaches 2.0? Is there any expected timeframe for 2.0? If this is not something that happens soon, I'd prefer this option to be actually usable. Would this imply adding a configuration option with the old sort order as default? |
We will still be able to opt in fixes that are version gated by adding
We do not have a concrete deadline for 2.0. |
@tanriol Would you mind rebasing this against the |
Coming back to this: do I understand correctly that |
Yes, that is correct, though I'd suggest waiting til after #4022 has been merged since there have been some related changes in the AST (ImplItemKind was folded into AssocItemKind, Existential variant was dropped, etc.) Also, I don't think this will need to be version gated any more since it'll be rolled into the 2.x release |
656d901
to
8ca28ff
Compare
8ca28ff
to
31b8ef2
Compare
The CI errors in
Looks like this is the result of rust-lang/rust#70240 |
@calebcartwright Does anything else need to be improved? |
We're in another round of rustc-ap updates that'll be blockers for this. #4100 will get those issues sorted, and once those make their way into the master branch you should be able to rebase to resolve |
Thank you, subscribed to the linked bug. |
Do I understand correctly that it's #4106 now? |
Correct |
The tests were modified in fa75ef4 (part of rust-lang#2535), probably accidentally as the comments documenting the old expectations were kept.
No functional change.
Just for consistency with other use-statement parts.
31b8ef2
to
8c0e580
Compare
@calebcartwright Rebased and green. |
I believe this is good to merge now, any objections @topecongiro? |
My apologies for the late review. LGTM, thank you! |
This change has been initially discussed in rust-lang/style-team#143 and is motivated by the following example from using
nom
:I've covered imports with
use
(including renames),mod
andextern crate
statements (including renames), and item names. Is there anything else I've missed?Technically this is a breaking change; however, in most cases it results in more readable code, so I'd consider it a bugfix. The only case I know that this change makes worse is names including fixed-width hex value which are ordered fine today but may become misordered
because the comparison runs between numerical segments of different length. I've thought about making this change configurable or version-gating it, but could not find out whether the config is available in some TLS, while some changed code is called via
Ord
impls and passing down the config explicitly is going to be a bigger refactoring.The second commit reverts a change introduced in fa75ef4 (#2535) that was likely unintentional as the comments in the tests still documented the old behavior.