mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Merge remote-tracking branch 'upstream/master' into another-subtree-sync
This commit is contained in:
commit
757da8c617
@ -2062,7 +2062,7 @@ use sit;
|
||||
Controls the strategy for how imports are grouped together.
|
||||
|
||||
- **Default value**: `Preserve`
|
||||
- **Possible values**: `Preserve`, `StdExternalCrate`
|
||||
- **Possible values**: `Preserve`, `StdExternalCrate`, `One`
|
||||
- **Stable**: No
|
||||
|
||||
#### `Preserve` (default):
|
||||
@ -2108,6 +2108,23 @@ use super::update::convert_publish_payload;
|
||||
use crate::models::Event;
|
||||
```
|
||||
|
||||
#### `One`:
|
||||
|
||||
Discard existing import groups, and create a single group for everything
|
||||
|
||||
```rust
|
||||
use super::schema::{Context, Payload};
|
||||
use super::update::convert_publish_payload;
|
||||
use crate::models::Event;
|
||||
use alloc::alloc::Layout;
|
||||
use broker::database::PooledConnection;
|
||||
use chrono::Utc;
|
||||
use core::f32;
|
||||
use juniper::{FieldError, FieldResult};
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
```
|
||||
|
||||
## `reorder_modules`
|
||||
|
||||
Reorder `mod` declarations alphabetically in group.
|
||||
|
@ -112,6 +112,8 @@ pub enum GroupImportsTactic {
|
||||
/// 2. other imports
|
||||
/// 3. `self` / `crate` / `super` imports
|
||||
StdExternalCrate,
|
||||
/// Discard existing groups, and create a single group for everything
|
||||
One,
|
||||
}
|
||||
|
||||
#[config_type]
|
||||
|
@ -118,7 +118,9 @@ fn rewrite_reorderable_or_regroupable_items(
|
||||
};
|
||||
|
||||
let mut regrouped_items = match context.config.group_imports() {
|
||||
GroupImportsTactic::Preserve => vec![normalized_items],
|
||||
GroupImportsTactic::Preserve | GroupImportsTactic::One => {
|
||||
vec![normalized_items]
|
||||
}
|
||||
GroupImportsTactic::StdExternalCrate => group_imports(normalized_items),
|
||||
};
|
||||
|
||||
|
17
tests/source/configs/group_imports/One-merge_imports.rs
Normal file
17
tests/source/configs/group_imports/One-merge_imports.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// rustfmt-group_imports: One
|
||||
// rustfmt-imports_granularity: Crate
|
||||
use chrono::Utc;
|
||||
use super::update::convert_publish_payload;
|
||||
|
||||
use juniper::{FieldError, FieldResult};
|
||||
use uuid::Uuid;
|
||||
use alloc::alloc::Layout;
|
||||
|
||||
use std::sync::Arc;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use broker::database::PooledConnection;
|
||||
|
||||
use super::schema::{Context, Payload};
|
||||
use core::f32;
|
||||
use crate::models::Event;
|
7
tests/source/configs/group_imports/One-nested.rs
Normal file
7
tests/source/configs/group_imports/One-nested.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// rustfmt-group_imports: One
|
||||
mod test {
|
||||
use crate::foo::bar;
|
||||
|
||||
use std::path;
|
||||
use crate::foo::bar2;
|
||||
}
|
16
tests/source/configs/group_imports/One-no_reorder.rs
Normal file
16
tests/source/configs/group_imports/One-no_reorder.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// rustfmt-group_imports: One
|
||||
// rustfmt-reorder_imports: false
|
||||
use chrono::Utc;
|
||||
use super::update::convert_publish_payload;
|
||||
|
||||
use juniper::{FieldError, FieldResult};
|
||||
use uuid::Uuid;
|
||||
use alloc::alloc::Layout;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use broker::database::PooledConnection;
|
||||
|
||||
use super::schema::{Context, Payload};
|
||||
use core::f32;
|
||||
use crate::models::Event;
|
15
tests/source/configs/group_imports/One.rs
Normal file
15
tests/source/configs/group_imports/One.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// rustfmt-group_imports: One
|
||||
use chrono::Utc;
|
||||
use super::update::convert_publish_payload;
|
||||
|
||||
use juniper::{FieldError, FieldResult};
|
||||
use uuid::Uuid;
|
||||
use alloc::alloc::Layout;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use broker::database::PooledConnection;
|
||||
|
||||
use super::schema::{Context, Payload};
|
||||
use core::f32;
|
||||
use crate::models::Event;
|
14
tests/target/configs/group_imports/One-merge_imports.rs
Normal file
14
tests/target/configs/group_imports/One-merge_imports.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// rustfmt-group_imports: One
|
||||
// rustfmt-imports_granularity: Crate
|
||||
use super::{
|
||||
schema::{Context, Payload},
|
||||
update::convert_publish_payload,
|
||||
};
|
||||
use crate::models::Event;
|
||||
use alloc::{alloc::Layout, vec::Vec};
|
||||
use broker::database::PooledConnection;
|
||||
use chrono::Utc;
|
||||
use core::f32;
|
||||
use juniper::{FieldError, FieldResult};
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
6
tests/target/configs/group_imports/One-nested.rs
Normal file
6
tests/target/configs/group_imports/One-nested.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// rustfmt-group_imports: One
|
||||
mod test {
|
||||
use crate::foo::bar;
|
||||
use crate::foo::bar2;
|
||||
use std::path;
|
||||
}
|
12
tests/target/configs/group_imports/One-no_reorder.rs
Normal file
12
tests/target/configs/group_imports/One-no_reorder.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// rustfmt-group_imports: One
|
||||
// rustfmt-reorder_imports: false
|
||||
use chrono::Utc;
|
||||
use super::update::convert_publish_payload;
|
||||
use juniper::{FieldError, FieldResult};
|
||||
use uuid::Uuid;
|
||||
use alloc::alloc::Layout;
|
||||
use std::sync::Arc;
|
||||
use broker::database::PooledConnection;
|
||||
use super::schema::{Context, Payload};
|
||||
use core::f32;
|
||||
use crate::models::Event;
|
11
tests/target/configs/group_imports/One.rs
Normal file
11
tests/target/configs/group_imports/One.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// rustfmt-group_imports: One
|
||||
use super::schema::{Context, Payload};
|
||||
use super::update::convert_publish_payload;
|
||||
use crate::models::Event;
|
||||
use alloc::alloc::Layout;
|
||||
use broker::database::PooledConnection;
|
||||
use chrono::Utc;
|
||||
use core::f32;
|
||||
use juniper::{FieldError, FieldResult};
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
Loading…
Reference in New Issue
Block a user