diff --git a/src/expr.rs b/src/expr.rs index 7380dc4850ec..46e7e500f227 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2578,10 +2578,10 @@ fn rewrite_assignment( // The left hand side must contain everything up to, and including, the // assignment operator. -pub fn rewrite_assign_rhs>( +pub fn rewrite_assign_rhs, R: Rewrite>( context: &RewriteContext, lhs: S, - ex: &ast::Expr, + ex: &R, shape: Shape, ) -> Option { let lhs = lhs.into(); @@ -2596,9 +2596,9 @@ pub fn rewrite_assign_rhs>( Some(lhs + &rhs) } -fn choose_rhs( +fn choose_rhs( context: &RewriteContext, - expr: &ast::Expr, + expr: &R, shape: Shape, orig_rhs: Option, ) -> Option { diff --git a/src/items.rs b/src/items.rs index fa697157ea32..e0bf02abe65a 100644 --- a/src/items.rs +++ b/src/items.rs @@ -111,7 +111,7 @@ impl Rewrite for ast::Local { // 1 = trailing semicolon; let nested_shape = shape.sub_width(1)?; - result = rewrite_assign_rhs(context, result, ex, nested_shape)?; + result = rewrite_assign_rhs(context, result, &**ex, nested_shape)?; } result.push(';'); @@ -550,7 +550,7 @@ impl<'a> FmtVisitor<'a> { ast::VariantData::Unit(..) => if let Some(ref expr) = field.node.disr_expr { let lhs = format!("{} =", field.node.name); // 1 = ',' - rewrite_assign_rhs(&context, lhs, expr, shape.sub_width(1)?)? + rewrite_assign_rhs(&context, lhs, &**expr, shape.sub_width(1)?)? } else { field.node.name.to_string() }, @@ -1593,7 +1593,7 @@ fn rewrite_static( rewrite_assign_rhs( context, lhs, - expr, + &**expr, Shape::legacy(remaining_width, offset.block_only()), ).and_then(|res| { recover_comment_removed(res, static_parts.span, context)