From 20bbca682b1e30793ca9e46ab81c7dcbf9b865ad Mon Sep 17 00:00:00 2001 From: vallentin Date: Sun, 17 Jan 2021 18:33:47 +0100 Subject: [PATCH] Fixed semicolon getting moved into comment (fixes #4646) --- src/formatting/items.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/formatting/items.rs b/src/formatting/items.rs index 7b199df9698..a982efb72df 100644 --- a/src/formatting/items.rs +++ b/src/formatting/items.rs @@ -434,6 +434,11 @@ impl<'a> FmtVisitor<'a> { FnBraceStyle::None, )?; + // If `result` ends with a comment, then remember to add a newline + if last_line_contains_single_line_comment(&result) { + result.push_str(&indent.to_string_with_newline(context.config)); + } + // Re-attach semicolon result.push(';');