-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! new lint:
source_item_ordering
- Loading branch information
Showing
11 changed files
with
268 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
10 changes: 10 additions & 0 deletions
10
tests/ui-toml/arbitrary_source_item_ordering/default_exp/clippy.toml
This file contains 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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
trait-assoc-item-kinds-order = ["const", "type", "fn"] | ||
source-item-ordering = ["enum", "impl", "module", "struct", "trait"] | ||
module-item-order-groupings = [ | ||
["modules", ["extern_crate", "mod", "foreign_mod"]], | ||
["use", ["use"]], | ||
["macros", ["macro"]], | ||
["global_asm", ["global_asm"]], | ||
["UPPER_SNAKE_CASE", ["static", "const"]], | ||
["PascalCase", ["ty_alias", "opaque_ty", "enum", "struct", "union", "trait", "trait_alias", "impl"]], | ||
["lower_snake_case", ["fn"]] | ||
] | ||
|
1 change: 1 addition & 0 deletions
1
tests/ui-toml/arbitrary_source_item_ordering/only_enum/clippy.toml
This file contains 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 @@ | ||
source-item-ordering = ["enum"] |
1 change: 1 addition & 0 deletions
1
tests/ui-toml/arbitrary_source_item_ordering/only_impl/clippy.toml
This file contains 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 @@ | ||
source-item-ordering = ["impl"] |
1 change: 1 addition & 0 deletions
1
tests/ui-toml/arbitrary_source_item_ordering/only_trait/clippy.toml
This file contains 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 @@ | ||
source-item-ordering = ["trait"] |
16 changes: 16 additions & 0 deletions
16
tests/ui-toml/arbitrary_source_item_ordering/ordering_only_enum.only_enum.stderr
This file contains 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,16 @@ | ||
error: incorrect ordering of items (must be alphabetically ordered) | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_enum.rs:22:5 | ||
| | ||
LL | A, | ||
| ^ | ||
| | ||
note: should be placed before `B` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_enum.rs:21:5 | ||
| | ||
LL | 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: aborting due to 1 previous error | ||
|
43 changes: 43 additions & 0 deletions
43
tests/ui-toml/arbitrary_source_item_ordering/ordering_only_enum.rs
This file contains 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,43 @@ | ||
//@aux-build:../../ui/auxiliary/proc_macros.rs | ||
//@revisions: only_enum | ||
//@[only_enum] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/only_enum | ||
|
||
#![allow(dead_code)] | ||
#![warn(clippy::arbitrary_source_item_ordering)] | ||
|
||
fn main() {} | ||
|
||
struct StructUnordered { | ||
b: bool, | ||
a: bool, | ||
} | ||
|
||
enum EnumOrdered { | ||
A, | ||
B, | ||
} | ||
|
||
enum EnumUnordered { | ||
B, | ||
A, | ||
} | ||
|
||
trait TraitUnordered { | ||
const B: bool; | ||
const A: bool; | ||
|
||
type SomeType; | ||
|
||
fn b(); | ||
fn a(); | ||
} | ||
|
||
trait TraitUnorderedItemKinds { | ||
type SomeType; | ||
|
||
const A: bool; | ||
|
||
fn a(); | ||
} | ||
|
||
const ZIS_SHOULD_BE_AT_THE_TOP: () = (); |
40 changes: 40 additions & 0 deletions
40
tests/ui-toml/arbitrary_source_item_ordering/ordering_only_impl.only_impl.stderr
This file contains 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_only_impl.rs:43:8 | ||
| | ||
LL | fn a() {} | ||
| ^ | ||
| | ||
note: should be placed before `b` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_impl.rs:42: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 impl items (defined order: [Const, Type, Fn]) | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_impl.rs:45:5 | ||
| | ||
LL | type SomeType = i8; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: should be placed before `a` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_impl.rs:43:5 | ||
| | ||
LL | fn a() {} | ||
| ^^^^^^^^^ | ||
|
||
error: incorrect ordering of impl items (defined order: [Const, Type, Fn]) | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_impl.rs:47:5 | ||
| | ||
LL | const A: bool = true; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: should be placed before `SomeType` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_impl.rs:45:5 | ||
| | ||
LL | type SomeType = i8; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
67 changes: 67 additions & 0 deletions
67
tests/ui-toml/arbitrary_source_item_ordering/ordering_only_impl.rs
This file contains 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,67 @@ | ||
//@aux-build:../../ui/auxiliary/proc_macros.rs | ||
//@revisions: only_impl | ||
//@[only_impl] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/only_impl | ||
|
||
#![allow(dead_code)] | ||
#![warn(clippy::arbitrary_source_item_ordering)] | ||
|
||
fn main() {} | ||
|
||
struct StructUnordered { | ||
b: bool, | ||
a: bool, | ||
} | ||
|
||
struct BasicStruct {} | ||
|
||
trait BasicTrait { | ||
const A: bool; | ||
|
||
type SomeType; | ||
|
||
fn b(); | ||
fn a(); | ||
} | ||
|
||
enum EnumUnordered { | ||
B, | ||
A, | ||
} | ||
|
||
trait TraitUnordered { | ||
const B: bool; | ||
const A: bool; | ||
|
||
type SomeType; | ||
|
||
fn b(); | ||
fn a(); | ||
} | ||
|
||
impl BasicTrait for StructUnordered { | ||
fn b() {} | ||
fn a() {} | ||
|
||
type SomeType = i8; | ||
|
||
const A: bool = true; | ||
} | ||
|
||
trait TraitUnorderedItemKinds { | ||
type SomeType; | ||
|
||
const A: bool; | ||
|
||
fn a(); | ||
} | ||
|
||
const ZIS_SHOULD_BE_AT_THE_TOP: () = (); | ||
|
||
impl BasicTrait for BasicStruct { | ||
const A: bool = true; | ||
|
||
type SomeType = i8; | ||
|
||
fn a() {} | ||
fn b() {} | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/ui-toml/arbitrary_source_item_ordering/ordering_only_trait.only_trait.stderr
This file contains 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_only_trait.rs:32:11 | ||
| | ||
LL | const A: bool; | ||
| ^ | ||
| | ||
note: should be placed before `B` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_trait.rs:31:11 | ||
| | ||
LL | const B: bool; | ||
| ^ | ||
= 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_only_trait.rs:37:8 | ||
| | ||
LL | fn a(); | ||
| ^ | ||
| | ||
note: should be placed before `b` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_trait.rs:36:8 | ||
| | ||
LL | fn b(); | ||
| ^ | ||
|
||
error: incorrect ordering of trait items (defined order: [Const, Type, Fn]) | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_trait.rs:43:5 | ||
| | ||
LL | const A: bool; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
note: should be placed before `SomeType` | ||
--> tests/ui-toml/arbitrary_source_item_ordering/ordering_only_trait.rs:41:5 | ||
| | ||
LL | type SomeType; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
48 changes: 48 additions & 0 deletions
48
tests/ui-toml/arbitrary_source_item_ordering/ordering_only_trait.rs
This file contains 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,48 @@ | ||
//@aux-build:../../ui/auxiliary/proc_macros.rs | ||
//@revisions: only_trait | ||
//@[only_trait] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/only_trait | ||
|
||
#![allow(dead_code)] | ||
#![warn(clippy::arbitrary_source_item_ordering)] | ||
|
||
fn main() {} | ||
|
||
struct StructUnordered { | ||
b: bool, | ||
a: bool, | ||
} | ||
|
||
trait TraitOrdered { | ||
const A: bool; | ||
const B: bool; | ||
|
||
type SomeType; | ||
|
||
fn a(); | ||
fn b(); | ||
} | ||
|
||
enum EnumUnordered { | ||
B, | ||
A, | ||
} | ||
|
||
trait TraitUnordered { | ||
const B: bool; | ||
const A: bool; | ||
|
||
type SomeType; | ||
|
||
fn b(); | ||
fn a(); | ||
} | ||
|
||
trait TraitUnorderedItemKinds { | ||
type SomeType; | ||
|
||
const A: bool; | ||
|
||
fn a(); | ||
} | ||
|
||
const ZIS_SHOULD_BE_AT_THE_TOP: () = (); |