Add reorder_impl_items config option
This commit is contained in:
parent
d48cbedfe4
commit
94f5a05a6a
@ -1413,6 +1413,42 @@ mod sit;
|
||||
**Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantic
|
||||
of the original source code.
|
||||
|
||||
## `reorder_impl_items`
|
||||
|
||||
Reorder impl items. `type` and `const` are put first, then macros and methods.
|
||||
|
||||
- **Default value**: `false`
|
||||
- **Possible values**: `true`, `false`
|
||||
- **Stable**: No
|
||||
|
||||
#### `false` (default)
|
||||
|
||||
```rust
|
||||
struct Dummy;
|
||||
|
||||
impl Iterator for Dummy {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
|
||||
type Item = i32;
|
||||
}
|
||||
```
|
||||
|
||||
#### `true`
|
||||
|
||||
```rust
|
||||
struct Dummy;
|
||||
|
||||
impl Iterator for Dummy {
|
||||
type Item = i32;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## `report_todo`
|
||||
|
||||
Report `TODO` items in comments.
|
||||
|
@ -75,6 +75,7 @@ create_config! {
|
||||
reorder_imported_names: bool, true, false,
|
||||
"Reorder lists of names in import statements alphabetically";
|
||||
reorder_modules: bool, true, false, "Reorder module statemtents alphabetically in group";
|
||||
reorder_impl_items: bool, false, false, "Reorder impl items";
|
||||
|
||||
// Spaces around punctuation
|
||||
binop_separator: SeparatorPlace, SeparatorPlace::Front, false,
|
||||
|
11
tests/source/configs/reorder_impl_items/false.rs
Normal file
11
tests/source/configs/reorder_impl_items/false.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// rustfmt-reorder_impl_items: false
|
||||
|
||||
struct Dummy;
|
||||
|
||||
impl Iterator for Dummy {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
|
||||
type Item = i32;
|
||||
}
|
11
tests/source/configs/reorder_impl_items/true.rs
Normal file
11
tests/source/configs/reorder_impl_items/true.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// rustfmt-reorder_impl_items: true
|
||||
|
||||
struct Dummy;
|
||||
|
||||
impl Iterator for Dummy {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
|
||||
type Item = i32;
|
||||
}
|
11
tests/target/configs/reorder_impl_items/false.rs
Normal file
11
tests/target/configs/reorder_impl_items/false.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// rustfmt-reorder_impl_items: false
|
||||
|
||||
struct Dummy;
|
||||
|
||||
impl Iterator for Dummy {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
|
||||
type Item = i32;
|
||||
}
|
11
tests/target/configs/reorder_impl_items/true.rs
Normal file
11
tests/target/configs/reorder_impl_items/true.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// rustfmt-reorder_impl_items: true
|
||||
|
||||
struct Dummy;
|
||||
|
||||
impl Iterator for Dummy {
|
||||
type Item = i32;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
None
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user