Add reorder_impl_items config option

This commit is contained in:
Seiichi Uchida 2018-04-04 14:57:30 +09:00
parent d48cbedfe4
commit 94f5a05a6a
6 changed files with 81 additions and 0 deletions

View File

@ -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.

View File

@ -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,

View 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;
}

View 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;
}

View 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;
}

View 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
}
}