-
Notifications
You must be signed in to change notification settings - Fork 1.7k
add impl-ordering-except-fn-names
config field for arbitrary_source_item_ordering
#14782
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
Open
relaxcn
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
relaxcn:issue-14739
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
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
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
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
1 change: 1 addition & 0 deletions
1
tests/ui-toml/arbitrary_source_item_ordering/exceptions/clippy.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
impl-ordering-except-fn-names = ["new"] |
40 changes: 40 additions & 0 deletions
40
tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.exceptions.stderr
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
error: incorrect ordering of items (must be alphabetically ordered) | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.rs:35:8 | ||
| | ||
LL | fn a() {} | ||
| ^ | ||
| | ||
note: should be placed before `b` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.rs:31:8 | ||
| | ||
LL | fn b() {} | ||
| ^ | ||
= note: `-D clippy::arbitrary-source-item-ordering` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::arbitrary_source_item_ordering)]` | ||
|
||
error: incorrect ordering of items (must be alphabetically ordered) | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.rs:47:8 | ||
| | ||
LL | fn b() {} | ||
| ^ | ||
| | ||
note: should be placed before `c` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.rs:46:8 | ||
| | ||
LL | fn c() {} | ||
| ^ | ||
|
||
error: incorrect ordering of items (must be alphabetically ordered) | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.rs:59:8 | ||
| | ||
LL | fn a() {} | ||
| ^ | ||
| | ||
note: should be placed before `c` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.rs:58:8 | ||
| | ||
LL | fn c() {} | ||
| ^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
65 changes: 65 additions & 0 deletions
65
tests/ui-toml/arbitrary_source_item_ordering/ordering_exceptions.rs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//@aux-build:../../ui/auxiliary/proc_macros.rs | ||
//@revisions: exceptions | ||
//@[exceptions] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/exceptions | ||
|
||
#![allow(dead_code)] | ||
#![warn(clippy::arbitrary_source_item_ordering)] | ||
|
||
struct BasicStruct1 {} | ||
|
||
impl BasicStruct1 { | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
fn a() {} | ||
fn b() {} | ||
} | ||
|
||
struct BasicStruct2 {} | ||
|
||
impl BasicStruct2 { | ||
fn a() {} | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
fn b() {} | ||
} | ||
|
||
struct BasicStruct3 {} | ||
|
||
impl BasicStruct3 { | ||
fn b() {} | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
fn a() {} | ||
//~^ arbitrary_source_item_ordering | ||
} | ||
|
||
struct BasicStruct4 {} | ||
|
||
impl BasicStruct4 { | ||
fn a() {} | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
fn c() {} | ||
fn b() {} | ||
//~^ arbitrary_source_item_ordering | ||
} | ||
|
||
struct BasicStruct5 {} | ||
|
||
impl BasicStruct5 { | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
fn b() {} | ||
fn c() {} | ||
fn a() {} | ||
//~^ arbitrary_source_item_ordering | ||
} | ||
|
||
fn main() { | ||
// test code goes here | ||
} |
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
Oops, something went wrong.
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.
This happens too early as type sorting hasn't happened yet.
You'll have to move the kind order check on line 353 to happen before the name check at line 351 and then insert this in between.
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.
This change is only to skip the function names that we don't want to sort.
I don't want to care about if it is one of the two compared objects, I just skip it.
If I change the code to this:
Then you will find a uitest error when you run command
TESTNAME="ordering_exceptions" cargo uitest
.The first function will always participate in the sorting.