Skip to content

Commit 94f5a05

Browse files
committed
Add reorder_impl_items config option
1 parent d48cbed commit 94f5a05

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed

Configurations.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,42 @@ mod sit;
14131413
**Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantic
14141414
of the original source code.
14151415

1416+
## `reorder_impl_items`
1417+
1418+
Reorder impl items. `type` and `const` are put first, then macros and methods.
1419+
1420+
- **Default value**: `false`
1421+
- **Possible values**: `true`, `false`
1422+
- **Stable**: No
1423+
1424+
#### `false` (default)
1425+
1426+
```rust
1427+
struct Dummy;
1428+
1429+
impl Iterator for Dummy {
1430+
fn next(&mut self) -> Option<Self::Item> {
1431+
None
1432+
}
1433+
1434+
type Item = i32;
1435+
}
1436+
```
1437+
1438+
#### `true`
1439+
1440+
```rust
1441+
struct Dummy;
1442+
1443+
impl Iterator for Dummy {
1444+
type Item = i32;
1445+
1446+
fn next(&mut self) -> Option<Self::Item> {
1447+
None
1448+
}
1449+
}
1450+
```
1451+
14161452
## `report_todo`
14171453

14181454
Report `TODO` items in comments.

src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ create_config! {
7575
reorder_imported_names: bool, true, false,
7676
"Reorder lists of names in import statements alphabetically";
7777
reorder_modules: bool, true, false, "Reorder module statemtents alphabetically in group";
78+
reorder_impl_items: bool, false, false, "Reorder impl items";
7879

7980
// Spaces around punctuation
8081
binop_separator: SeparatorPlace, SeparatorPlace::Front, false,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// rustfmt-reorder_impl_items: false
2+
3+
struct Dummy;
4+
5+
impl Iterator for Dummy {
6+
fn next(&mut self) -> Option<Self::Item> {
7+
None
8+
}
9+
10+
type Item = i32;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// rustfmt-reorder_impl_items: true
2+
3+
struct Dummy;
4+
5+
impl Iterator for Dummy {
6+
fn next(&mut self) -> Option<Self::Item> {
7+
None
8+
}
9+
10+
type Item = i32;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// rustfmt-reorder_impl_items: false
2+
3+
struct Dummy;
4+
5+
impl Iterator for Dummy {
6+
fn next(&mut self) -> Option<Self::Item> {
7+
None
8+
}
9+
10+
type Item = i32;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// rustfmt-reorder_impl_items: true
2+
3+
struct Dummy;
4+
5+
impl Iterator for Dummy {
6+
type Item = i32;
7+
8+
fn next(&mut self) -> Option<Self::Item> {
9+
None
10+
}
11+
}

0 commit comments

Comments
 (0)