diff options
| author | Tom Milligan <tom@reinfer.io> | 2022-03-05 23:01:43 +0000 |
|---|---|---|
| committer | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2022-04-11 17:46:33 -0500 |
| commit | 4f3f87fb9a629db8bf0c6e04604320cd028f79e8 (patch) | |
| tree | 350184a15928f9ecde0971096167952f502e4fc5 | |
| parent | 2d9bc460108df4e3587be82e36a58f2fb3f4813f (diff) | |
| download | rust-4f3f87fb9a629db8bf0c6e04604320cd028f79e8.tar.gz rust-4f3f87fb9a629db8bf0c6e04604320cd028f79e8.zip | |
group_imports: test and document non-consecutive imports
| -rw-r--r-- | Configurations.md | 6 | ||||
| -rw-r--r-- | tests/source/configs/group_imports/StdExternalCrate-non_consecutive.rs | 27 | ||||
| -rw-r--r-- | tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs | 18 |
3 files changed, 50 insertions, 1 deletions
diff --git a/Configurations.md b/Configurations.md index a47439b9ba9..dc8d38267a8 100644 --- a/Configurations.md +++ b/Configurations.md @@ -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. diff --git a/tests/source/configs/group_imports/StdExternalCrate-non_consecutive.rs b/tests/source/configs/group_imports/StdExternalCrate-non_consecutive.rs new file mode 100644 index 00000000000..f239a0efa08 --- /dev/null +++ b/tests/source/configs/group_imports/StdExternalCrate-non_consecutive.rs @@ -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; diff --git a/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs b/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs new file mode 100644 index 00000000000..ecc8ede02cc --- /dev/null +++ b/tests/target/configs/group_imports/StdExternalCrate-non_consecutive.rs @@ -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; |
