Fixes comma added to comment in where-clause
This commit is contained in:
parent
041f113159
commit
8d2c4157e6
10
src/items.rs
10
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)? {
|
if is_impl_single_line(context, items.as_slice(), &result, &where_clause_str, item)? {
|
||||||
result.push_str(&where_clause_str);
|
result.push_str(&where_clause_str);
|
||||||
if where_clause_str.contains('\n') || last_line_contains_single_line_comment(&result) {
|
if where_clause_str.contains('\n') {
|
||||||
// if the where_clause contains extra comments AND
|
// If there is only one where-clause predicate
|
||||||
// there is only one where-clause predicate
|
// and the where-clause spans multiple lines,
|
||||||
// recover the suppressed comma in single line where_clause formatting
|
// then recover the suppressed comma in single line where-clause formatting
|
||||||
if generics.where_clause.predicates.len() == 1 {
|
if generics.where_clause.predicates.len() == 1 {
|
||||||
result.push(',');
|
result.push(',');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if where_clause_str.contains('\n') || last_line_contains_single_line_comment(&result) {
|
||||||
result.push_str(&format!("{sep}{{{sep}}}"));
|
result.push_str(&format!("{sep}{{{sep}}}"));
|
||||||
} else {
|
} else {
|
||||||
result.push_str(" {}");
|
result.push_str(" {}");
|
||||||
|
@ -32,6 +32,11 @@ impl<T> Foo for T
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #5941
|
||||||
|
impl T where (): Clone // Should not add comma to comment
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// #1823
|
// #1823
|
||||||
default impl Trait for X {}
|
default impl Trait for X {}
|
||||||
default unsafe impl Trait for Y {}
|
default unsafe impl Trait for Y {}
|
||||||
|
Loading…
Reference in New Issue
Block a user