]> git.lizzy.rs Git - rust.git/blobdiff - Configurations.md
Remove unnecessary use of Box in `format_function_type`
[rust.git] / Configurations.md
index da027d10e706f03f4c5f9057cc9ece9e7661044e..07a336d93fa9a5e405d6312293c7c293cdd63c2a 100644 (file)
@@ -6,7 +6,7 @@ A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
 
 ```toml
 indent_style = "Block"
-reorder_imported_names = true
+reorder_imports = false
 ```
 
 Each configuration option is either stable or unstable.
@@ -64,7 +64,12 @@ fn main() {
 
 ```rust
 fn main() {
-    if lorem_ipsum && dolor_sit && amet_consectetur && lorem_sit && dolor_consectetur && amet_ipsum
+    if lorem_ipsum
+        && dolor_sit
+        && amet_consectetur
+        && lorem_sit
+        && dolor_consectetur
+        && amet_ipsum
         && lorem_consectetur
     {
         // ...
@@ -76,7 +81,12 @@ fn main() {
 
 ```rust
 fn main() {
-    if lorem_ipsum && dolor_sit && amet_consectetur && lorem_sit && dolor_consectetur && amet_ipsum
+    if lorem_ipsum
+       && dolor_sit
+       && amet_consectetur
+       && lorem_sit
+       && dolor_consectetur
+       && amet_ipsum
        && lorem_consectetur
     {
         // ...
@@ -342,7 +352,8 @@ fn main() {
     let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
         || barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
 
-    let sum = 123456789012345678901234567890 + 123456789012345678901234567890
+    let sum = 123456789012345678901234567890
+        + 123456789012345678901234567890
         + 123456789012345678901234567890;
 
     let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -357,7 +368,8 @@ fn main() {
     let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo ||
         barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
 
-    let sum = 123456789012345678901234567890 + 123456789012345678901234567890 +
+    let sum = 123456789012345678901234567890 +
+        123456789012345678901234567890 +
         123456789012345678901234567890;
 
     let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
@@ -579,9 +591,12 @@ Don't reformat anything
 
 ## `error_on_line_overflow`
 
-Error if unable to get all lines within `max_width`, except for comments and string literals.
+Error if Rustfmt is unable to get all lines within `max_width`, except for comments and string
+literals. If this happens, then it is a bug in Rustfmt. You might be able to work around the bug by
+refactoring your code to avoid long/complex expressions, usually by extracting a local variable or
+using a shorter name.
 
-- **Default value**: `true`
+- **Default value**: `false`
 - **Possible values**: `true`, `false`
 - **Stable**: No
 
@@ -889,7 +904,7 @@ See also [`control_brace_style`](#control_brace_style).
 
 ## `where_single_line`
 
-To force single line where layout
+Forces the `where` clause to be laid out on a single line.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
@@ -1039,8 +1054,10 @@ Item layout inside a imports block
 ```rust
 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
 
-use foo::{aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
-          eeeeeeeeeeeeeeeeee, ffffffffffffffffff};
+use foo::{
+    aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
+    eeeeeeeeeeeeeeeeee, ffffffffffffffffff,
+};
 ```
 
 #### `"Horizontal"`:
@@ -1058,27 +1075,55 @@ use foo::{aaa, bbb, ccc, ddd, eee, fff};
 ```rust
 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
 
-use foo::{aaaaaaaaaaaaaaaaaa,
-          bbbbbbbbbbbbbbbbbb,
-          cccccccccccccccccc,
-          dddddddddddddddddd,
-          eeeeeeeeeeeeeeeeee,
-          ffffffffffffffffff};
+use foo::{
+    aaaaaaaaaaaaaaaaaa,
+    bbbbbbbbbbbbbbbbbb,
+    cccccccccccccccccc,
+    dddddddddddddddddd,
+    eeeeeeeeeeeeeeeeee,
+    ffffffffffffffffff,
+};
 ```
 
 #### `"Vertical"`:
 
 ```rust
-use foo::{xxx,
-          yyy,
-          zzz};
+use foo::{
+    xxx,
+    yyy,
+    zzz,
+};
 
-use foo::{aaa,
-          bbb,
-          ccc,
-          ddd,
-          eee,
-          fff};
+use foo::{
+    aaa,
+    bbb,
+    ccc,
+    ddd,
+    eee,
+    fff,
+};
+```
+
+## `merge_imports`
+
+Merge multiple imports into a single nested import.
+
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `false` (default):
+
+```rust
+use foo::{a, c, d};
+use foo::{b, g};
+use foo::{e, f};
+```
+
+#### `true`:
+
+```rust
+use foo::{a, b, c, d, e, f, g};
 ```
 
 
@@ -1237,72 +1282,41 @@ fn dolor() -> usize {}
 fn adipiscing() -> usize {}
 ```
 
-## `reorder_imported_names`
+## `remove_nested_parens`
 
-Reorder lists of names in import statements alphabetically
+Remove nested parens.
 
-- **Default value**: `false`
+- **Defalut value**: `false`,
 - **Possible values**: `true`, `false`
 - **Stable**: No
 
 #### `false` (default):
-
 ```rust
-use super::{lorem, ipsum, dolor, sit};
+fn main() {
+    ((((foo()))));
+}
 ```
 
 #### `true`:
-
 ```rust
-use super::{dolor, ipsum, lorem, sit};
+fn main() {
+    (foo());
+}
 ```
 
-See also [`reorder_imports`](#reorder_imports).
 
 ## `reorder_imports`
 
-Reorder import statements alphabetically
-
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
-- **Stable**: No
-
-#### `false` (default):
-
-```rust
-use lorem;
-use ipsum;
-use dolor;
-use sit;
-```
+Reorder import and extern crate statements alphabetically in groups (a group is
+separated by a newline).
 
-#### `true`:
-
-```rust
-use dolor;
-use ipsum;
-use lorem;
-use sit;
-```
-
-See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
-
-## `reorder_imports_in_group`
-
-Reorder import statements in group
-
-- **Default value**: `false`
+- **Default value**: `true`
 - **Possible values**: `true`, `false`
 - **Stable**: No
 
-**Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
-
 #### `true` (default):
 
 ```rust
-use std::io;
-use std::mem;
-
 use dolor;
 use ipsum;
 use lorem;
@@ -1311,72 +1325,13 @@ use sit;
 
 #### `false`:
 
-
 ```rust
-use dolor;
-use ipsum;
 use lorem;
+use ipsum;
+use dolor;
 use sit;
-use std::io;
-use std::mem;
 ```
 
-See also [`reorder_imports`](#reorder_imports).
-
-## `reorder_extern_crates`
-
-Reorder `extern crate` statements alphabetically
-
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
-- **Stable**: No
-
-#### `true` (default):
-
-```rust
-extern crate dolor;
-extern crate ipsum;
-extern crate lorem;
-extern crate sit;
-```
-
-#### `false`:
-
-```rust
-extern crate lorem;
-extern crate ipsum;
-
-extern crate dolor;
-extern crate sit;
-```
-
-See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
-
-## `reorder_extern_crates_in_group`
-
-Reorder `extern crate` statements in group
-
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
-- **Stable**: No
-
-#### `false` (default):
-
-This value has no influence beyond the effect of the [`reorder_extern_crates`](#reorder_extern_crates) option. Set [`reorder_extern_crates`](#reorder_extern_crates) to `false` if you do not want `extern crate` groups to be collapsed and ordered.
-
-#### `true`:
-
-**Note:** This only takes effect when [`reorder_extern_crates`](#reorder_extern_crates) is set to `true`.
-
-```rust
-extern crate a;
-extern crate b;
-
-extern crate dolor;
-extern crate ipsum;
-extern crate lorem;
-extern crate sit;
-```
 
 ## `reorder_modules`
 
@@ -1413,6 +1368,42 @@ mod sit;
 **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantic
 of the original source code.
 
+## `reorder_impl_items`
+
+Reorder impl items. `type` and `const` are put first, then macros and methods.
+
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `false` (default)
+
+```rust
+struct Dummy;
+
+impl Iterator for Dummy {
+    fn next(&mut self) -> Option<Self::Item> {
+        None
+    }
+
+    type Item = i32;
+}
+```
+
+#### `true`
+
+```rust
+struct Dummy;
+
+impl Iterator for Dummy {
+    type Item = i32;
+
+    fn next(&mut self) -> Option<Self::Item> {
+        None
+    }
+}
+```
+
 ## `report_todo`
 
 Report `TODO` items in comments.
@@ -2087,7 +2078,7 @@ fn foo() {
 
 ## `required_version`
 
-Require a specific version of rustfmt. If you want to make sure that the 
+Require a specific version of rustfmt. If you want to make sure that the
 specific version of rustfmt is used in your CI, use this option.
 
 - **Default value**: `CARGO_PKG_VERSION`
@@ -2112,7 +2103,7 @@ Whether to use colored output or not.
 
 ## `unstable_features`
 
-Enable unstable featuers on stable channel.
+Enable unstable features on stable channel.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`