]> git.lizzy.rs Git - rust.git/blobdiff - Configurations.md
Merge pull request #3012 from YaLTeR/fix-issue-2496
[rust.git] / Configurations.md
index 07a336d93fa9a5e405d6312293c7c293cdd63c2a..6fcd0609b6569912c96977412f3307b9492e95c5 100644 (file)
@@ -275,11 +275,11 @@ fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
 
 Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'.
 
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
-- **Stable**: No
+- **Default value**: `Default`
+- **Possible values**: `Default`, `Off`, `Max`
+- **Stable**: Yes
 
-#### `true` (default):
+#### `Default` (default):
 
 ```rust
 enum Lorem {
@@ -309,7 +309,7 @@ fn main() {
 }
 ```
 
-#### `false`:
+#### `Off`:
 
 ```rust
 enum Lorem {
@@ -337,6 +337,24 @@ fn main() {
 }
 ```
 
+#### `Max`:
+
+```rust
+enum Lorem {
+    Ipsum,
+    Dolor(bool),
+    Sit { amet: Consectetur, adipiscing: Elit },
+}
+
+fn main() {
+    lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
+
+    let lorem = Lorem { ipsum: dolor, sit: amet };
+
+    let lorem = if ipsum { dolor } else { sit };
+}
+```
+
 ## `binop_separator`
 
 Where to put a binary operator when a binary expression goes multiline.
@@ -988,6 +1006,76 @@ fn main() {
 
 See also [`max_width`](#max_width).
 
+## `format_macro_matchers`
+
+Format the metavariable matching patterns in macros.
+
+- **Default value**: `false`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `false` (default):
+
+```rust
+macro_rules! foo {
+    ($a: ident : $b: ty) => {
+        $a(42): $b;
+    };
+    ($a: ident $b: ident $c: ident) => {
+        $a = $b + $c;
+    };
+}
+```
+
+#### `true`:
+
+```rust
+macro_rules! foo {
+    ($a:ident : $b:ty) => {
+        $a(42): $b;
+    };
+    ($a:ident $b:ident $c:ident) => {
+        $a = $b + $c;
+    };
+}
+```
+
+See also [`format_macro_bodies`](#format_macro_bodies).
+
+
+## `format_macro_bodies`
+
+Format the bodies of macros.
+
+- **Default value**: `true`
+- **Possible values**: `true`, `false`
+- **Stable**: No
+
+#### `true` (default):
+
+```rust
+macro_rules! foo {
+    ($a: ident : $b: ty) => {
+        $a(42): $b;
+    };
+    ($a: ident $b: ident $c: ident) => {
+        $a = $b + $c;
+    };
+}
+```
+
+#### `false`:
+
+```rust
+macro_rules! foo {
+    ($a: ident : $b: ty) => { $a(42): $b; };
+    ($a: ident $b: ident $c: ident) => { $a=$b+$c; };
+}
+```
+
+See also [`format_macro_matchers`](#format_macro_matchers).
+
+
 ## `hard_tabs`
 
 Use tab characters for indentation, spaces for alignment
@@ -1019,18 +1107,11 @@ See also: [`tab_spaces`](#tab_spaces).
 
 Indent style of imports
 
-- **Default Value**: `"Visual"`
+- **Default Value**: `"Block"`
 - **Possible values**: `"Block"`, `"Visual"`
 - **Stable**: No
 
-#### `"Visual"` (default):
-
-```rust
-use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
-          zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz};
-```
-
-#### `"Block"`:
+#### `"Block"` (default):
 
 ```rust
 use foo::{
@@ -1039,6 +1120,13 @@ use foo::{
 };
 ```
 
+#### `"Visual"`:
+
+```rust
+use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
+          zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz};
+```
+
 See also: [`imports_layout`](#imports_layout).
 
 ## `imports_layout`
@@ -1215,7 +1303,7 @@ fn main() {
     });
 
     match lorem {
-        None => if ipsum {
+        None => |ipsum| {
             println!("Hello World");
         },
         Some(dolor) => foo(),
@@ -1236,7 +1324,7 @@ fn main() {
 
     match lorem {
         None => {
-            if ipsum {
+            |ipsum| {
                 println!("Hello World");
             }
         }
@@ -1250,17 +1338,36 @@ fn main() {
 
 Unix or Windows line endings
 
-- **Default value**: `"Unix"`
-- **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
+- **Default value**: `"Auto"`
+- **Possible values**: `"Auto"`, `"Native"`, `"Unix"`, `"Windows"`
 - **Stable**: Yes
 
+#### `Auto` (default):
+
+The newline style is detected automatically on a per-file basis. Files
+with mixed line endings will be converted to the first detected line
+ending style.
+
+#### `Native`
+
+Line endings will be converted to `\r\n` on Windows and `\n` on all
+other platforms.
+
+#### `Unix`
+
+Line endings will be converted to `\n`.
+
+#### `Windows`
+
+Line endings will be converted to `\r\n`.
+
 ## `normalize_comments`
 
 Convert /* */ comments to // comments where possible
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
-- **Stable**: Yes
+- **Stable**: No
 
 #### `false` (default):
 
@@ -1286,21 +1393,22 @@ fn adipiscing() -> usize {}
 
 Remove nested parens.
 
-- **Defalut value**: `false`,
+- **Default value**: `true`,
 - **Possible values**: `true`, `false`
-- **Stable**: No
+- **Stable**: Yes
 
-#### `false` (default):
+
+#### `true` (default):
 ```rust
 fn main() {
-    ((((foo()))));
+    (foo());
 }
 ```
 
-#### `true`:
+#### `false`:
 ```rust
 fn main() {
-    (foo());
+    ((((foo()))));
 }
 ```
 
@@ -1312,7 +1420,7 @@ separated by a newline).
 
 - **Default value**: `true`
 - **Possible values**: `true`, `false`
-- **Stable**: No
+- **Stable**: Yes
 
 #### `true` (default):
 
@@ -1339,7 +1447,7 @@ Reorder `mod` declarations alphabetically in group.
 
 - **Default value**: `true`
 - **Possible values**: `true`, `false`
-- **Stable**: No
+- **Stable**: Yes
 
 #### `true` (default)
 
@@ -1589,52 +1697,6 @@ fn main() {
 }
 ```
 
-## `spaces_within_parens_and_brackets`
-
-Put spaces within non-empty generic arguments, parentheses, and square brackets
-
-- **Default value**: `false`
-- **Possible values**: `true`, `false`
-- **Stable**: No
-
-#### `false` (default):
-
-```rust
-// generic arguments
-fn lorem<T: Eq>(t: T) {
-    // body
-}
-
-// non-empty parentheses
-fn lorem<T: Eq>(t: T) {
-    let lorem = (ipsum, dolor);
-}
-
-// non-empty square brackets
-fn lorem<T: Eq>(t: T) {
-    let lorem: [usize; 2] = [ipsum, dolor];
-}
-```
-
-#### `true`:
-
-```rust
-// generic arguments
-fn lorem< T: Eq >( t: T ) {
-    // body
-}
-
-// non-empty parentheses
-fn lorem< T: Eq >( t: T ) {
-    let lorem = ( ipsum, dolor );
-}
-
-// non-empty square brackets
-fn lorem< T: Eq >( t: T ) {
-    let lorem: [ usize; 2 ] = [ ipsum, dolor ];
-}
-```
-
 ## `struct_lit_single_line`
 
 Put small struct literals on a single line
@@ -1810,7 +1872,7 @@ Use field initialize shorthand if possible.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
-- **Stable**: No
+- **Stable**: Yes
 
 #### `false` (default):
 
@@ -1852,7 +1914,7 @@ Replace uses of the try! macro by the ? shorthand
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
-- **Stable**: No
+- **Stable**: Yes
 
 #### `false` (default):
 
@@ -1877,7 +1939,7 @@ Break comments to fit on the line
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
-- **Stable**: Yes
+- **Stable**: No
 
 #### `false` (default):
 
@@ -1930,13 +1992,6 @@ fn main() {
 
 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
 
-## `write_mode`
-
-What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
-
-- **Default value**: `"Overwrite"`
-- **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`
-- **Stable**: No
 
 ## `blank_lines_upper_bound`
 
@@ -1951,7 +2006,7 @@ lines are found, they are trimmed down to match this integer.
 Original Code:
 
 ```rust
-#![rustfmt_skip]
+#![rustfmt::skip]
 
 fn foo() {
     println!("a");
@@ -1980,7 +2035,7 @@ fn bar() {
 }
 ```
 
-#### `2` (default):
+#### `2`:
 ```rust
 fn foo() {
     println!("a");
@@ -2010,7 +2065,7 @@ them, additional blank lines are inserted.
 Original Code (rustfmt will not change it with the default value of `0`):
 
 ```rust
-#![rustfmt_skip]
+#![rustfmt::skip]
 
 fn foo() {
     println!("a");
@@ -2036,45 +2091,6 @@ fn bar() {
 }
 ```
 
-## `remove_blank_lines_at_start_or_end_of_block`
-
-Remove blank lines at the start or the end of a block.
-
-- **Default value**: `true`
-- **Possible values**: `true`, `false`
-- **Stable**: No
-
-#### `true`
-
-```rust
-fn foo() {
-    let msg = {
-        let mut str = String::new();
-        str.push_str("hello, ");
-        str.push_str("world!");
-        str
-    };
-    println!("{}", msg);
-}
-```
-
-#### `false`
-
-```rust
-fn foo() {
-
-    let msg = {
-
-        let mut str = String::new();
-        str.push_str("hello, ");
-        str.push_str("world!");
-        str
-
-    };
-    println!("{}", msg);
-
-}
-```
 
 ## `required_version`
 
@@ -2107,7 +2123,7 @@ Enable unstable features on stable channel.
 
 - **Default value**: `false`
 - **Possible values**: `true`, `false`
-- **Stable**: Yes
+- **Stable**: No
 
 ## `license_template_path`
 
@@ -2151,7 +2167,31 @@ ignore = [
 If you want to ignore every file under `examples/`, put the following to your config file:
 
 ```toml
-ignore [
+ignore [
     "examples",
 ]
 ```
+
+## `edition`
+
+Specifies which edition is used by the parser.
+
+- **Default value**: `2015`
+- **Possible values**: `2015`, `2018`
+- **Stable**: No
+
+### Example
+
+If you want to format code that requires edition 2018, add the following to your config file:
+
+```toml
+edition = "2018"
+```
+
+## `emit_mode`
+
+Internal option
+
+## `make_backup`
+
+Internal option, use `--backup`