From d6a3f2cfe9028e0c20b4e44d57024e81f0f38d00 Mon Sep 17 00:00:00 2001 From: Chad Stearns Date: Mon, 16 Dec 2019 13:21:25 -0500 Subject: [PATCH] Removed denest and stopped manually newlining --- src/fmt/expr.rs | 29 ++--------------------------- tests/test_format.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/fmt/expr.rs b/src/fmt/expr.rs index 7b36004c4e..7ae73ab879 100644 --- a/src/fmt/expr.rs +++ b/src/fmt/expr.rs @@ -103,11 +103,9 @@ pub fn fmt_expr<'a>( }; for loc_pattern in loc_patterns.iter() { - fmt_pattern(buf, denest_pattern(&loc_pattern.value), indent, true); + fmt_pattern(buf, &loc_pattern.value, indent, true); - if arguments_are_multiline { - newline(buf, indent); - } else { + if !arguments_are_multiline { buf.push(' '); } } @@ -287,29 +285,6 @@ pub fn empty_line_before_expr<'a>(expr: &'a Expr<'a>) -> bool { } } -pub fn denest_pattern<'a>(pattern: &'a Pattern<'a>) -> &Pattern { - match pattern { - Pattern::SpaceBefore(unwrapped_pattern, _) - | Pattern::SpaceAfter(unwrapped_pattern, _) => denest_pattern(unwrapped_pattern), - Pattern::Nested(nested_pattern) => denest_pattern(nested_pattern), - Pattern::Identifier(_) - | Pattern::GlobalTag(_) - | Pattern::PrivateTag(_) - | Pattern::Apply(_, _) - | Pattern::RecordDestructure(_) - | Pattern::RecordField(_, _) - | Pattern::IntLiteral(_) - | Pattern::NonBase10Literal { .. } - | Pattern::FloatLiteral(_) - | Pattern::StrLiteral(_) - | Pattern::BlockStrLiteral(_) - | Pattern::EmptyRecordLiteral - | Pattern::Underscore - | Pattern::Malformed(_) - | Pattern::QualifiedIdentifier(_) => pattern, - } -} - pub fn is_multiline_pattern<'a>(pattern: &'a Pattern<'a>) -> bool { match pattern { Pattern::SpaceBefore(_, spaces) | Pattern::SpaceAfter(_, spaces) => { diff --git a/tests/test_format.rs b/tests/test_format.rs index b94447e1b6..34d41b2121 100644 --- a/tests/test_format.rs +++ b/tests/test_format.rs @@ -519,6 +519,17 @@ mod test_format { identity 43 "# )); + + expr_formats_same(indoc!( + r#" + identity = \a + b + # its b!! + -> a + + identity 43 + "# + )); } // RECORD LITERALS