From 55fc5b5ec2c43da2aa876c0d032411dee168e800 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sun, 8 Oct 2017 22:35:45 +0900 Subject: [PATCH] Get rid of rewrite_struct_field_type() --- src/items.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/items.rs b/src/items.rs index 90b75a82f62f..d731cb8858af 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1362,20 +1362,6 @@ pub fn rewrite_struct_field_prefix( }) } -fn rewrite_struct_field_type( - context: &RewriteContext, - last_line_width: usize, - field: &ast::StructField, - spacing: &str, - shape: Shape, -) -> Option { - let ty_shape = shape.offset_left(last_line_width + spacing.len())?; - field - .ty - .rewrite(context, ty_shape) - .map(|ty| format!("{}{}", spacing, ty)) -} - impl Rewrite for ast::StructField { fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { rewrite_struct_field(context, self, shape, 0) @@ -1427,10 +1413,10 @@ pub fn rewrite_struct_field( if prefix.is_empty() && !attrs_str.is_empty() && attrs_extendable && spacing.is_empty() { spacing.push(' '); } - let ty_rewritten = rewrite_struct_field_type(context, overhead, field, &spacing, shape); - if let Some(ref ty) = ty_rewritten { + let ty_shape = shape.offset_left(overhead + spacing.len())?; + if let Some(ref ty) = field.ty.rewrite(context, ty_shape) { if !ty.contains('\n') { - return Some(attr_prefix + ty); + return Some(attr_prefix + &spacing + ty); } }