diff options
| author | Christian Duerr <contact@christianduerr.com> | 2019-03-30 18:37:37 +0100 |
|---|---|---|
| committer | Christian Duerr <contact@christianduerr.com> | 2019-03-30 18:37:37 +0100 |
| commit | 919bee89909d93972b6c8da333b58ed03d9b3591 (patch) | |
| tree | c92e2365e33142e8b8d99496ac56def29c518e8a | |
| parent | dfa94d150555da40780413d7f1a1378565208c99 (diff) | |
Enable overflow_delimited_expr for structs
This fixes https://github.com/rust-lang/rustfmt/issues/3482.
| -rw-r--r-- | src/expr.rs | 1 | ||||
| -rw-r--r-- | tests/source/match_overflow_expr.rs | 53 | ||||
| -rw-r--r-- | tests/target/match_overflow_expr.rs | 50 |
3 files changed, 104 insertions, 0 deletions
diff --git a/src/expr.rs b/src/expr.rs index 8d241dff1f9..f383eaca36f 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1346,6 +1346,7 @@ pub fn can_be_overflowed_expr( ast::ExprKind::Match(..) => { (context.use_block_indent() && args_len == 1) || (context.config.indent_style() == IndentStyle::Visual && args_len > 1) + || context.config.overflow_delimited_expr() } ast::ExprKind::If(..) | ast::ExprKind::IfLet(..) diff --git a/tests/source/match_overflow_expr.rs b/tests/source/match_overflow_expr.rs new file mode 100644 index 00000000000..91275a89429 --- /dev/null +++ b/tests/source/match_overflow_expr.rs @@ -0,0 +1,53 @@ +// rustfmt-overflow_delimited_expr: true + +fn main() { + println!( + "Foobar: {}", + match "input" { + "a" => "", + "b" => "", + "c" => "", + "d" => "", + "e" => "", + "f" => "", + "g" => "", + "h" => "", + "i" => "", + "j" => "", + "k" => "", + "l" => "", + "m" => "", + "n" => "", + "o" => "", + "p" => "", + "q" => "", + "r" => "Rust", + } + ); +} + +fn main() { + println!( + "Very Long Input String Which Makes It Impossible To Fit On The Same Line: {}", + match "input" { + "a" => "", + "b" => "", + "c" => "", + "d" => "", + "e" => "", + "f" => "", + "g" => "", + "h" => "", + "i" => "", + "j" => "", + "k" => "", + "l" => "", + "m" => "", + "n" => "", + "o" => "", + "p" => "", + "q" => "", + "r" => "Rust", + } + ); +} diff --git a/tests/target/match_overflow_expr.rs b/tests/target/match_overflow_expr.rs new file mode 100644 index 00000000000..b817879d1f4 --- /dev/null +++ b/tests/target/match_overflow_expr.rs @@ -0,0 +1,50 @@ +// rustfmt-overflow_delimited_expr: true + +fn main() { + println!("Foobar: {}", match "input" { + "a" => "", + "b" => "", + "c" => "", + "d" => "", + "e" => "", + "f" => "", + "g" => "", + "h" => "", + "i" => "", + "j" => "", + "k" => "", + "l" => "", + "m" => "", + "n" => "", + "o" => "", + "p" => "", + "q" => "", + "r" => "Rust", + }); +} + +fn main() { + println!( + "Very Long Input String Which Makes It Impossible To Fit On The Same Line: {}", + match "input" { + "a" => "", + "b" => "", + "c" => "", + "d" => "", + "e" => "", + "f" => "", + "g" => "", + "h" => "", + "i" => "", + "j" => "", + "k" => "", + "l" => "", + "m" => "", + "n" => "", + "o" => "", + "p" => "", + "q" => "", + "r" => "Rust", + } + ); +} |
