about summary refs log tree commit diff
path: root/src/expr.rs
diff options
context:
space:
mode:
authortopecongiro <seuchida@gmail.com>2017-05-19 19:30:06 +0900
committertopecongiro <seuchida@gmail.com>2017-05-23 11:37:12 +0900
commit520340481d4238d63a4eef2555fba45405dc74b4 (patch)
tree5052d62dd3d9c7d771b1bd753ec29d4247e44ab1 /src/expr.rs
parent13af774e5596fc1e3ff5097efad74c8988b1282d (diff)
Allow macro rewrite to fail on rhs
Diffstat (limited to 'src/expr.rs')
-rw-r--r--src/expr.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 066c7faa43e..a2c5f1c077c 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -2080,11 +2080,18 @@ pub fn rewrite_assign_rhs<S: Into<String>>(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()