@@ -434,7 +434,7 @@ impl<'a> FmtVisitor<'a> {
434
434
let fmt = ListFormatting {
435
435
tactic : DefinitiveListTactic :: Vertical ,
436
436
separator : "," ,
437
- trailing_separator : SeparatorTactic :: from_bool ( self . config . enum_trailing_comma ) ,
437
+ trailing_separator : self . config . trailing_comma ,
438
438
shape : Shape :: legacy ( budget, self . block_indent ) ,
439
439
ends_with_newline : true ,
440
440
config : self . config ,
@@ -526,7 +526,6 @@ pub fn format_impl(context: &RewriteContext, item: &ast::Item, offset: Indent) -
526
526
offset. block_only( ) ) ,
527
527
context. config. where_density,
528
528
"{" ,
529
- true ,
530
529
None ) ) ;
531
530
532
531
if try_opt ! ( is_impl_single_line( context, & items, & result, & where_clause_str, & item) ) {
@@ -795,7 +794,6 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
795
794
offset. block_only( ) ) ,
796
795
where_density,
797
796
"{" ,
798
- has_body,
799
797
None ) ) ;
800
798
// If the where clause cannot fit on the same line,
801
799
// put the where clause on a new line
@@ -952,7 +950,7 @@ fn format_struct_struct(context: &RewriteContext,
952
950
let fmt = ListFormatting {
953
951
tactic : tactic,
954
952
separator : "," ,
955
- trailing_separator : context. config . struct_trailing_comma ,
953
+ trailing_separator : context. config . trailing_comma ,
956
954
shape : Shape :: legacy ( budget, item_indent) ,
957
955
ends_with_newline : true ,
958
956
config : context. config ,
@@ -1010,7 +1008,6 @@ fn format_tuple_struct(context: &RewriteContext,
1010
1008
Shape :: legacy( where_budget, offset. block_only( ) ) ,
1011
1009
Density :: Compressed ,
1012
1010
";" ,
1013
- false ,
1014
1011
None ) )
1015
1012
}
1016
1013
None => "" . to_owned ( ) ,
@@ -1103,7 +1100,6 @@ pub fn rewrite_type_alias(context: &RewriteContext,
1103
1100
Shape :: legacy( where_budget, indent) ,
1104
1101
context. config. where_density,
1105
1102
"=" ,
1106
- false ,
1107
1103
Some ( span. hi) ) ) ;
1108
1104
result. push_str ( & where_clause_str) ;
1109
1105
result. push_str ( " = " ) ;
@@ -1645,7 +1641,6 @@ fn rewrite_fn_base(context: &RewriteContext,
1645
1641
Shape :: legacy( where_budget, indent) ,
1646
1642
where_density,
1647
1643
"{" ,
1648
- has_body,
1649
1644
Some ( span. hi) ) ) ;
1650
1645
1651
1646
if last_line_width ( & result) + where_clause_str. len ( ) > context. config . max_width &&
@@ -1929,7 +1924,6 @@ fn rewrite_where_clause(context: &RewriteContext,
1929
1924
shape : Shape ,
1930
1925
density : Density ,
1931
1926
terminator : & str ,
1932
- allow_trailing_comma : bool ,
1933
1927
span_end : Option < BytePos > )
1934
1928
-> Option < String > {
1935
1929
if where_clause. predicates . is_empty ( ) {
@@ -1969,12 +1963,17 @@ fn rewrite_where_clause(context: &RewriteContext,
1969
1963
// FIXME: we don't need to collect here if the where_layout isn't
1970
1964
// HorizontalVertical.
1971
1965
let tactic = definitive_tactic ( & item_vec, context. config . where_layout , budget) ;
1972
- let use_trailing_comma = allow_trailing_comma && context. config . where_trailing_comma ;
1966
+
1967
+ let mut comma_tactic = context. config . trailing_comma ;
1968
+ // Kind of a hack because we don't usually have trailing commas in where clauses.
1969
+ if comma_tactic == SeparatorTactic :: Vertical {
1970
+ comma_tactic = SeparatorTactic :: Never ;
1971
+ }
1973
1972
1974
1973
let fmt = ListFormatting {
1975
1974
tactic : tactic,
1976
1975
separator : "," ,
1977
- trailing_separator : SeparatorTactic :: from_bool ( use_trailing_comma ) ,
1976
+ trailing_separator : comma_tactic ,
1978
1977
shape : Shape :: legacy ( budget, offset) ,
1979
1978
ends_with_newline : true ,
1980
1979
config : context. config ,
@@ -2034,7 +2033,6 @@ fn format_generics(context: &RewriteContext,
2034
2033
offset. block_only( ) ) ,
2035
2034
Density :: Tall ,
2036
2035
terminator,
2037
- true ,
2038
2036
Some ( span. hi) ) ) ;
2039
2037
result. push_str ( & where_clause_str) ;
2040
2038
if !force_same_line_brace &&
0 commit comments