diff options
Diffstat (limited to 'src/tools/rustfmt/Configurations.md')
| -rw-r--r-- | src/tools/rustfmt/Configurations.md | 61 |
1 files changed, 9 insertions, 52 deletions
diff --git a/src/tools/rustfmt/Configurations.md b/src/tools/rustfmt/Configurations.md index a47439b9ba9..8c84614352c 100644 --- a/src/tools/rustfmt/Configurations.md +++ b/src/tools/rustfmt/Configurations.md @@ -10,7 +10,7 @@ reorder_imports = false ``` Each configuration option is either stable or unstable. -Stable options can be used directly, while unstable options are opt-in. +Stable options can always be used, while unstable options are only available on a nightly toolchain and must be opted into. To enable unstable options, set `unstable_features = true` in `rustfmt.toml` or pass `--unstable-features` to rustfmt. # Configuration Options @@ -1065,7 +1065,7 @@ See also: [`tab_spaces`](#tab_spaces). Control the case of the letters in hexadecimal literal values - **Default value**: `Preserve` -- **Possible values**: `Upper`, `Lower` +- **Possible values**: `Preserve`, `Upper`, `Lower` - **Stable**: No (tracking issue: [#5081](https://github.com/rust-lang/rustfmt/issues/5081)) ## `hide_parse_errors` @@ -1473,26 +1473,6 @@ use core::slice; #[cfg(feature = "alloc")] use core::slice; ``` -## `license_template_path` - -Check whether beginnings of files match a license template. - -- **Default value**: `""` -- **Possible values**: path to a license template file -- **Stable**: No (tracking issue: [#3352](https://github.com/rust-lang/rustfmt/issues/3352)) - -A license template is a plain text file which is matched literally against the -beginning of each source file, except for `{}`-delimited blocks, which are -matched as regular expressions. The following license template therefore -matches strings like `// Copyright 2017 The Rust Project Developers.`, `// -Copyright 2018 The Rust Project Developers.`, etc.: - -``` -// Copyright {\d+} The Rust Project Developers. -``` - -`\{`, `\}` and `\\` match literal braces / backslashes. - ## `match_arm_blocks` Controls whether arm bodies are wrapped in cases where the first line of the body cannot fit on the same line as the `=>` operator. @@ -1705,6 +1685,8 @@ How imports should be grouped into `use` statements. Imports will be merged or s - **Possible values**: `Preserve`, `Crate`, `Module`, `Item`, `One` - **Stable**: No (tracking issue: [#4991](https://github.com/rust-lang/rustfmt/issues/4991)) +Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments. + #### `Preserve` (default): Do not change the granularity of any imports and preserve the original structure written by the developer. @@ -2061,12 +2043,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. @@ -2162,35 +2148,6 @@ mod sit; **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics of the original source code. -## `report_fixme` - -Report `FIXME` items in comments. - -- **Default value**: `"Never"` -- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"` -- **Stable**: No (tracking issue: [#3394](https://github.com/rust-lang/rustfmt/issues/3394)) - -Warns about any comments containing `FIXME` in them when set to `"Always"`. If -it contains a `#X` (with `X` being a number) in parentheses following the -`FIXME`, `"Unnumbered"` will ignore it. - -See also [`report_todo`](#report_todo). - - -## `report_todo` - -Report `TODO` items in comments. - -- **Default value**: `"Never"` -- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"` -- **Stable**: No (tracking issue: [#3393](https://github.com/rust-lang/rustfmt/issues/3393)) - -Warns about any comments containing `TODO` in them when set to `"Always"`. If -it contains a `#X` (with `X` being a number) in parentheses following the -`TODO`, `"Unnumbered"` will ignore it. - -See also [`report_fixme`](#report_fixme). - ## `required_version` Require a specific version of rustfmt. If you want to make sure that the |
