Skip to content

Commit c777002

Browse files
committed
replace where density with the boolean on_new_line
The density parameter of items::rewrite_where_clause was used only in a conditional, which evaluated to true only if the parameter was Density::Tall.
1 parent c2c48e2 commit c777002

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/items.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::comment::{
1515
FindUncommented,
1616
};
1717
use crate::config::lists::*;
18-
use crate::config::{BraceStyle, Config, Density, IndentStyle, Version};
18+
use crate::config::{BraceStyle, Config, IndentStyle, Version};
1919
use crate::expr::{
2020
format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, rewrite_assign_rhs_with,
2121
ExprType, RhsTactics,
@@ -703,7 +703,7 @@ pub(crate) fn format_impl(
703703
&generics.where_clause,
704704
context.config.brace_style(),
705705
Shape::legacy(where_budget, offset.block_only()),
706-
Density::Vertical,
706+
false,
707707
"{",
708708
where_span_end,
709709
self_ty.span.hi(),
@@ -1045,11 +1045,7 @@ pub(crate) fn format_trait(
10451045

10461046
// Rewrite where-clause.
10471047
if !generics.where_clause.predicates.is_empty() {
1048-
let where_density = if context.config.indent_style() == IndentStyle::Block {
1049-
Density::Compressed
1050-
} else {
1051-
Density::Tall
1052-
};
1048+
let where_on_new_line = context.config.indent_style() != IndentStyle::Block;
10531049

10541050
let where_budget = context.budget(last_line_width(&result));
10551051
let pos_before_where = if generic_bounds.is_empty() {
@@ -1063,7 +1059,7 @@ pub(crate) fn format_trait(
10631059
&generics.where_clause,
10641060
context.config.brace_style(),
10651061
Shape::legacy(where_budget, offset.block_only()),
1066-
where_density,
1062+
where_on_new_line,
10671063
"{",
10681064
None,
10691065
pos_before_where,
@@ -1382,7 +1378,7 @@ fn format_tuple_struct(
13821378
&generics.where_clause,
13831379
context.config.brace_style(),
13841380
Shape::legacy(where_budget, offset.block_only()),
1385-
Density::Compressed,
1381+
false,
13861382
";",
13871383
None,
13881384
body_hi,
@@ -1459,7 +1455,7 @@ fn rewrite_type_prefix(
14591455
&generics.where_clause,
14601456
context.config.brace_style(),
14611457
Shape::legacy(where_budget, indent),
1462-
Density::Vertical,
1458+
false,
14631459
"=",
14641460
None,
14651461
generics.span.hi(),
@@ -2211,7 +2207,7 @@ fn rewrite_fn_base(
22112207
where_clause,
22122208
context.config.brace_style(),
22132209
Shape::indented(indent, context.config),
2214-
Density::Tall,
2210+
true,
22152211
"{",
22162212
Some(span.hi()),
22172213
pos_before_where,
@@ -2564,7 +2560,7 @@ fn rewrite_where_clause(
25642560
where_clause: &ast::WhereClause,
25652561
brace_style: BraceStyle,
25662562
shape: Shape,
2567-
density: Density,
2563+
on_new_line: bool,
25682564
terminator: &str,
25692565
span_end: Option<BytePos>,
25702566
span_end_before_where: BytePos,
@@ -2646,7 +2642,7 @@ fn rewrite_where_clause(
26462642
} else {
26472643
terminator.len()
26482644
};
2649-
if density == Density::Tall
2645+
if on_new_line
26502646
|| preds_str.contains('\n')
26512647
|| shape.indent.width() + " where ".len() + preds_str.len() + end_length > shape.width
26522648
{
@@ -2737,7 +2733,7 @@ fn format_generics(
27372733
&generics.where_clause,
27382734
brace_style,
27392735
Shape::legacy(budget, offset.block_only()),
2740-
Density::Tall,
2736+
true,
27412737
"{",
27422738
Some(span.hi()),
27432739
span_end_before_where,

0 commit comments

Comments
 (0)