about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGambitingMan <nermin_dedovic@hotmail.com>2023-11-01 18:00:38 +0100
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>2023-11-01 20:21:05 -0500
commit8d2c4157e6ce88b40d9a49d837b2e600d47cd05c (patch)
tree0ebf0dd46a81f89bdab5e316831421a2f9841d75 /src
parent041f11315923b0e4b0328b3bb6366de9148c7b6b (diff)
downloadrust-8d2c4157e6ce88b40d9a49d837b2e600d47cd05c.tar.gz
rust-8d2c4157e6ce88b40d9a49d837b2e600d47cd05c.zip
Fixes comma added to comment in where-clause
Diffstat (limited to 'src')
-rw-r--r--src/items.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/items.rs b/src/items.rs
index edb5a5b629a..d6488ffd141 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -831,13 +831,15 @@ pub(crate) fn format_impl(
 
     if is_impl_single_line(context, items.as_slice(), &result, &where_clause_str, item)? {
         result.push_str(&where_clause_str);
-        if where_clause_str.contains('\n') || last_line_contains_single_line_comment(&result) {
-            // if the where_clause contains extra comments AND
-            // there is only one where-clause predicate
-            // recover the suppressed comma in single line where_clause formatting
+        if where_clause_str.contains('\n') {
+            // If there is only one where-clause predicate
+            // and the where-clause spans multiple lines,
+            // then recover the suppressed comma in single line where-clause formatting
             if generics.where_clause.predicates.len() == 1 {
                 result.push(',');
             }
+        }
+        if where_clause_str.contains('\n') || last_line_contains_single_line_comment(&result) {
             result.push_str(&format!("{sep}{{{sep}}}"));
         } else {
             result.push_str(" {}");