Merge remote-tracking branch 'upstream/master' into another-subtree-sync

This commit is contained in:
Caleb Cartwright 2021-10-24 13:45:19 -05:00
commit 757da8c617
11 changed files with 121 additions and 2 deletions

View File

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

View File

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

View File

@ -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),
};

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

View File

@ -0,0 +1,7 @@
// rustfmt-group_imports: One
mod test {
use crate::foo::bar;
use std::path;
use crate::foo::bar2;
}

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

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

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

View File

@ -0,0 +1,6 @@
// rustfmt-group_imports: One
mod test {
use crate::foo::bar;
use crate::foo::bar2;
use std::path;
}

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

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