group_imports: test and document non-consecutive imports

This commit is contained in:
Tom Milligan 2022-03-05 23:01:43 +00:00 committed by Caleb Cartwright
parent 2d9bc46010
commit 4f3f87fb9a
3 changed files with 50 additions and 1 deletions

View File

@ -2061,12 +2061,16 @@ use sit;
## `group_imports`
Controls the strategy for how imports are grouped together.
Controls the strategy for how consecutive imports are grouped together.
Controls the strategy for grouping sets of consecutive imports. Imports may contain newlines between imports and still be grouped together as a single set, but other statements between imports will result in different grouping sets.
- **Default value**: `Preserve`
- **Possible values**: `Preserve`, `StdExternalCrate`, `One`
- **Stable**: No (tracking issue: [#5083](https://github.com/rust-lang/rustfmt/issues/5083))
Each set of imports (one or more `use` statements, optionally separated by newlines) will be formatted independently. Other statements such as `mod ...` or `extern crate ...` will cause imports to not be grouped together.
#### `Preserve` (default):
Preserve the source file's import groups.

View File

@ -0,0 +1,27 @@
// rustfmt-group_imports: StdExternalCrate
use chrono::Utc;
use super::update::convert_publish_payload;
use juniper::{FieldError, FieldResult};
use uuid::Uuid;
use alloc::alloc::Layout;
extern crate uuid;
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,18 @@
// rustfmt-group_imports: StdExternalCrate
use alloc::alloc::Layout;
use chrono::Utc;
use juniper::{FieldError, FieldResult};
use uuid::Uuid;
use super::update::convert_publish_payload;
extern crate uuid;
use core::f32;
use std::sync::Arc;
use broker::database::PooledConnection;
use super::schema::{Context, Payload};
use crate::models::Event;