From 520340481d4238d63a4eef2555fba45405dc74b4 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Fri, 19 May 2017 19:30:06 +0900 Subject: [PATCH] Allow macro rewrite to fail on rhs --- src/expr.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 066c7faa43e0..a2c5f1c077ce 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2080,11 +2080,18 @@ pub fn rewrite_assign_rhs>(context: &RewriteContext, 0 }; // 1 = space between operator and rhs. - let max_width = try_opt!(shape.width.checked_sub(last_line_width + 1)); - let rhs = ex.rewrite(context, - Shape::offset(max_width, - shape.indent, - shape.indent.alignment + last_line_width + 1)); + let orig_shape = try_opt!(shape.block_indent(0).offset_left(last_line_width + 1)); + let rhs = match ex.node { + ast::ExprKind::Mac(ref mac) => { + match rewrite_macro(mac, None, context, orig_shape, MacroPosition::Expression) { + None if !context.snippet(ex.span).contains("\n") => { + context.snippet(ex.span).rewrite(context, orig_shape) + } + rhs @ _ => rhs, + } + } + _ => ex.rewrite(context, orig_shape), + }; fn count_line_breaks(src: &str) -> usize { src.chars().filter(|&x| x == '\n').count()