From 1b84623aac1221d10d251ac82370cf4393157613 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Mon, 2 Oct 2017 00:00:12 +0900 Subject: Use offset_left() --- src/types.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/types.rs b/src/types.rs index 311192889d3..6f6e02f4d92 100644 --- a/src/types.rs +++ b/src/types.rs @@ -439,7 +439,7 @@ impl Rewrite for ast::WherePredicate { // 6 = "for<> ".len() let used_width = lifetime_str.len() + type_str.len() + colon.len() + 6; - let ty_shape = try_opt!(shape.block_left(used_width)); + let ty_shape = try_opt!(shape.offset_left(used_width)); let bounds: Vec<_> = try_opt!( bounds .iter() @@ -553,10 +553,9 @@ impl Rewrite for ast::TyParamBound { tref.rewrite(context, shape) } ast::TyParamBound::TraitTyParamBound(ref tref, ast::TraitBoundModifier::Maybe) => { - let budget = try_opt!(shape.width.checked_sub(1)); Some(format!( "?{}", - try_opt!(tref.rewrite(context, Shape::legacy(budget, shape.indent + 1))) + try_opt!(tref.rewrite(context, try_opt!(shape.offset_left(1)))) )) } ast::TyParamBound::RegionTyParamBound(ref l) => l.rewrite(context, shape), @@ -624,11 +623,10 @@ impl Rewrite for ast::PolyTraitRef { // 6 is "for<> ".len() let extra_offset = lifetime_str.len() + 6; - let max_path_width = try_opt!(shape.width.checked_sub(extra_offset)); - let path_str = try_opt!(self.trait_ref.rewrite( - context, - Shape::legacy(max_path_width, shape.indent + extra_offset), - )); + let path_str = try_opt!( + self.trait_ref + .rewrite(context, try_opt!(shape.offset_left(extra_offset))) + ); Some( if context.config.spaces_within_angle_brackets() && !lifetime_str.is_empty() { -- cgit 1.4.1-3-g733a5 From eebad40932d6ea1fbdd4bd07212079a229abadb5 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Mon, 2 Oct 2017 00:00:48 +0900 Subject: Use a correct budget for where predicate --- src/items.rs | 6 ++++-- src/types.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/items.rs b/src/items.rs index 8fdfdb4110c..8dbc5e8882e 100644 --- a/src/items.rs +++ b/src/items.rs @@ -2484,7 +2484,9 @@ fn rewrite_where_clause_rfc_style( "\n".to_owned() + &block_shape.indent.to_string(context.config) }; - let clause_shape = block_shape.block_indent(context.config.tab_spaces()); + let clause_shape = try_opt!(block_shape.block_left(context.config.tab_spaces())); + // 1 = `,` + let clause_shape = try_opt!(clause_shape.sub_width(1)); // each clause on one line, trailing comma (except if suppress_comma) let span_start = where_clause.predicates[0].span().lo(); // If we don't have the start of the next span, then use the end of the @@ -2498,7 +2500,7 @@ fn rewrite_where_clause_rfc_style( terminator, |pred| pred.span().lo(), |pred| pred.span().hi(), - |pred| pred.rewrite(context, block_shape), + |pred| pred.rewrite(context, clause_shape), span_start, span_end, false, diff --git a/src/types.rs b/src/types.rs index 6f6e02f4d92..2d8b6285f74 100644 --- a/src/types.rs +++ b/src/types.rs @@ -463,7 +463,7 @@ impl Rewrite for ast::WherePredicate { let used_width = type_str.len() + colon.len(); let ty_shape = match context.config.where_style() { Style::Legacy => try_opt!(shape.block_left(used_width)), - Style::Rfc => shape.block_indent(context.config.tab_spaces()), + Style::Rfc => shape, }; let bounds: Vec<_> = try_opt!( bounds -- cgit 1.4.1-3-g733a5