From f7ef1f681cf026ee6e941f51de0fa9a3693e2153 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 16 Nov 2017 11:27:11 +0900 Subject: [PATCH] Use rewrite_assign_rhs() when rewriting associated type --- src/items.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/items.rs b/src/items.rs index e0bf02abe65..5f6c043bb4a 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1613,10 +1613,9 @@ pub fn rewrite_associated_type( ) -> Option { let prefix = format!("type {}", ident); - let type_bounds_str = if let Some(ty_param_bounds) = ty_param_bounds_opt { + let type_bounds_str = if let Some(ref bounds) = ty_param_bounds_opt { // 2 = ": ".len() let shape = Shape::indented(indent, context.config).offset_left(prefix.len() + 2)?; - let bounds: &[_] = ty_param_bounds; let bound_str = bounds .iter() .map(|ty_bound| ty_bound.rewrite(context, shape)) @@ -1631,14 +1630,10 @@ pub fn rewrite_associated_type( }; if let Some(ty) = ty_opt { - let ty_str = ty.rewrite( - context, - Shape::legacy( - context.budget(indent.block_indent + prefix.len() + 2), - indent.block_only(), - ), - )?; - Some(format!("{}{} = {};", prefix, type_bounds_str, ty_str)) + // 1 = `;` + let shape = Shape::indented(indent, context.config).sub_width(1)?; + let lhs = format!("{}{} =", prefix, type_bounds_str); + rewrite_assign_rhs(context, lhs, &**ty, shape).map(|s| s + ";") } else { Some(format!("{}{};", prefix, type_bounds_str)) }