From 18be76ea431fee298fd295500255b8287a30b7cc Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 13 Jul 2022 23:02:14 -0400 Subject: [PATCH] Don't keep comments right after the -> (at least not when the branch is a multiline expr!) --- crates/compiler/fmt/src/expr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compiler/fmt/src/expr.rs b/crates/compiler/fmt/src/expr.rs index 53867e929f..0cb4f3fc2c 100644 --- a/crates/compiler/fmt/src/expr.rs +++ b/crates/compiler/fmt/src/expr.rs @@ -773,14 +773,14 @@ fn fmt_when<'a, 'buf>( match expr.value { Expr::SpaceBefore(nested, spaces) => { - fmt_spaces_no_blank_lines(buf, spaces.iter(), indent + (INDENT * 2)); - if is_multiline_expr { buf.ensure_ends_with_newline(); } else { buf.spaces(1); } + fmt_comments_only(buf, spaces.iter(), NewlineAt::Bottom, indent + (INDENT * 2)); + nested.format_with_options( buf, Parens::NotNeeded,