Skip to content

Commit 757da8c

Browse files
Merge remote-tracking branch 'upstream/master' into another-subtree-sync
2 parents 051e2b4 + 599b2fd commit 757da8c

File tree

11 files changed

+121
-2
lines changed

11 files changed

+121
-2
lines changed

Configurations.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ use sit;
20622062
Controls the strategy for how imports are grouped together.
20632063

20642064
- **Default value**: `Preserve`
2065-
- **Possible values**: `Preserve`, `StdExternalCrate`
2065+
- **Possible values**: `Preserve`, `StdExternalCrate`, `One`
20662066
- **Stable**: No
20672067

20682068
#### `Preserve` (default):
@@ -2108,6 +2108,23 @@ use super::update::convert_publish_payload;
21082108
use crate::models::Event;
21092109
```
21102110

2111+
#### `One`:
2112+
2113+
Discard existing import groups, and create a single group for everything
2114+
2115+
```rust
2116+
use super::schema::{Context, Payload};
2117+
use super::update::convert_publish_payload;
2118+
use crate::models::Event;
2119+
use alloc::alloc::Layout;
2120+
use broker::database::PooledConnection;
2121+
use chrono::Utc;
2122+
use core::f32;
2123+
use juniper::{FieldError, FieldResult};
2124+
use std::sync::Arc;
2125+
use uuid::Uuid;
2126+
```
2127+
21112128
## `reorder_modules`
21122129

21132130
Reorder `mod` declarations alphabetically in group.

src/config/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ pub enum GroupImportsTactic {
112112
/// 2. other imports
113113
/// 3. `self` / `crate` / `super` imports
114114
StdExternalCrate,
115+
/// Discard existing groups, and create a single group for everything
116+
One,
115117
}
116118

117119
#[config_type]

src/reorder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ fn rewrite_reorderable_or_regroupable_items(
118118
};
119119

120120
let mut regrouped_items = match context.config.group_imports() {
121-
GroupImportsTactic::Preserve => vec![normalized_items],
121+
GroupImportsTactic::Preserve | GroupImportsTactic::One => {
122+
vec![normalized_items]
123+
}
122124
GroupImportsTactic::StdExternalCrate => group_imports(normalized_items),
123125
};
124126

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// rustfmt-group_imports: One
2+
// rustfmt-imports_granularity: Crate
3+
use chrono::Utc;
4+
use super::update::convert_publish_payload;
5+
6+
use juniper::{FieldError, FieldResult};
7+
use uuid::Uuid;
8+
use alloc::alloc::Layout;
9+
10+
use std::sync::Arc;
11+
use alloc::vec::Vec;
12+
13+
use broker::database::PooledConnection;
14+
15+
use super::schema::{Context, Payload};
16+
use core::f32;
17+
use crate::models::Event;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// rustfmt-group_imports: One
2+
mod test {
3+
use crate::foo::bar;
4+
5+
use std::path;
6+
use crate::foo::bar2;
7+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// rustfmt-group_imports: One
2+
// rustfmt-reorder_imports: false
3+
use chrono::Utc;
4+
use super::update::convert_publish_payload;
5+
6+
use juniper::{FieldError, FieldResult};
7+
use uuid::Uuid;
8+
use alloc::alloc::Layout;
9+
10+
use std::sync::Arc;
11+
12+
use broker::database::PooledConnection;
13+
14+
use super::schema::{Context, Payload};
15+
use core::f32;
16+
use crate::models::Event;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// rustfmt-group_imports: One
2+
use chrono::Utc;
3+
use super::update::convert_publish_payload;
4+
5+
use juniper::{FieldError, FieldResult};
6+
use uuid::Uuid;
7+
use alloc::alloc::Layout;
8+
9+
use std::sync::Arc;
10+
11+
use broker::database::PooledConnection;
12+
13+
use super::schema::{Context, Payload};
14+
use core::f32;
15+
use crate::models::Event;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// rustfmt-group_imports: One
2+
// rustfmt-imports_granularity: Crate
3+
use super::{
4+
schema::{Context, Payload},
5+
update::convert_publish_payload,
6+
};
7+
use crate::models::Event;
8+
use alloc::{alloc::Layout, vec::Vec};
9+
use broker::database::PooledConnection;
10+
use chrono::Utc;
11+
use core::f32;
12+
use juniper::{FieldError, FieldResult};
13+
use std::sync::Arc;
14+
use uuid::Uuid;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// rustfmt-group_imports: One
2+
mod test {
3+
use crate::foo::bar;
4+
use crate::foo::bar2;
5+
use std::path;
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// rustfmt-group_imports: One
2+
// rustfmt-reorder_imports: false
3+
use chrono::Utc;
4+
use super::update::convert_publish_payload;
5+
use juniper::{FieldError, FieldResult};
6+
use uuid::Uuid;
7+
use alloc::alloc::Layout;
8+
use std::sync::Arc;
9+
use broker::database::PooledConnection;
10+
use super::schema::{Context, Payload};
11+
use core::f32;
12+
use crate::models::Event;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// rustfmt-group_imports: One
2+
use super::schema::{Context, Payload};
3+
use super::update::convert_publish_payload;
4+
use crate::models::Event;
5+
use alloc::alloc::Layout;
6+
use broker::database::PooledConnection;
7+
use chrono::Utc;
8+
use core::f32;
9+
use juniper::{FieldError, FieldResult};
10+
use std::sync::Arc;
11+
use uuid::Uuid;

0 commit comments

Comments
 (0)