From bceaf184518798b786c081b50f8db5a6fd63217d Mon Sep 17 00:00:00 2001 From: David Bar-On Date: Tue, 2 Mar 2021 14:34:12 +0200 Subject: [PATCH] Changes per comments and moved test cases files(1) --- src/formatting/items.rs | 10 +++------- .../trait.rs | 0 .../trait.rs | 0 3 files changed, 3 insertions(+), 7 deletions(-) rename tests/source/{lhs-to-rhs-bewteen-comments => lhs-to-rhs-between-comments}/trait.rs (100%) rename tests/target/{lhs-to-rhs-bewteen-comments => lhs-to-rhs-between-comments}/trait.rs (100%) diff --git a/src/formatting/items.rs b/src/formatting/items.rs index 42b026de587..241a071d817 100644 --- a/src/formatting/items.rs +++ b/src/formatting/items.rs @@ -1204,13 +1204,9 @@ pub(crate) fn format_trait( } result.push_str(&where_clause_str); } - let pre_block_span = if !generics.where_clause.predicates.is_empty() { - mk_sp(generics.where_clause.span.hi(), item.span.hi()) - } else if !generic_bounds.is_empty() { - mk_sp(generic_bounds.last().unwrap().span().hi(), item.span.hi()) - } else { - item.span - }; + + /* Note: `where_clause` always exists; Span is empty when no where clause in the code */ + let pre_block_span = mk_sp(generics.where_clause.span.hi(), item.span.hi()); let pre_block_snippet = context.snippet(pre_block_span); if let Some(lo) = pre_block_snippet.find('/') { // 1 = `{` diff --git a/tests/source/lhs-to-rhs-bewteen-comments/trait.rs b/tests/source/lhs-to-rhs-between-comments/trait.rs similarity index 100% rename from tests/source/lhs-to-rhs-bewteen-comments/trait.rs rename to tests/source/lhs-to-rhs-between-comments/trait.rs diff --git a/tests/target/lhs-to-rhs-bewteen-comments/trait.rs b/tests/target/lhs-to-rhs-between-comments/trait.rs similarity index 100% rename from tests/target/lhs-to-rhs-bewteen-comments/trait.rs rename to tests/target/lhs-to-rhs-between-comments/trait.rs