-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
run rustfmt on libtest folder #34085
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
Merged
+1
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why not
Less, Equal, Greater? That makes the most sense to me.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.
That's not alphabetical, which is how rustfmt appears to be sorting it.
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.
I understand, but I disagree with
rustfmton this one.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.
What about consistency?
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.
Well, the rule can be generalized to all
enums by sorting variants by declaration order. This has the added benefit of inheriting any grouping that the author put in. Taking a few random examples from MIR to show how this rule would provide benefit:rustc::mir::repr::TerminatorKindhas a few intuitive groups.Goto,If,Switch, andSwitchIntare basic branches, going to one of a list of possible targets based on a simple condition.ResumeandReturnboth signal exiting from some sort of scope, andDrop,DropAndReplace,Call, andAssertare all not inherently terminators, more like statements that can panic. By sorting by definition order, those groups would all be imported next to each other.rustc::mir::repr::Lvalueis similarly grouped:Var,Temp, andArgare function-local,StaticandReturnPointerrepresent externally created variables, andProjectionis its own thing.rustc::mir::repr::BorrowKinddoes not really have a division into groups. However, it is ordered by increasing permissions:Sharedpointers can't be guaranteed unique access and can't mutate,Uniquepointers form the in-between of unique access without mutability, andMutpointers have all the permissions. Importing them in this order makes sense because it is the natural order to view the options in.Essentially, developers already sort their
enums in a logical, helpful way, and it makes sense to reuse that for import order.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.
Worth filing an issue against rustfmt about this. My personal experience is that in 99% of cases, programmers don't order their imports and it's not worth the extra effort for the other 1%. In particular I'm not sure if it helps anybody - I agree the enum ordering is sensible, but I don't see any concrete benefit.