about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarcus Klaas <mail@marcusklaas.nl>2015-09-12 14:31:51 +0200
committerMarcus Klaas <mail@marcusklaas.nl>2015-09-12 14:31:51 +0200
commitffa7e8d59972d7a61fa3e8192210ce17d7c86ee4 (patch)
tree14bf470d70ecbe0af5ca0f94c5066ecab3fb496d
parent764793b2e655b14f1aa98e8e966835e0cc5d3914 (diff)
Prevent generation of bogus comment in some function calls
This would happen when the callee contained parentheses.
-rw-r--r--src/expr.rs3
-rw-r--r--tests/source/closure.rs6
-rw-r--r--tests/target/closure.rs6
3 files changed, 14 insertions, 1 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 530cf8eda47..b5fd09e0e01 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -40,7 +40,8 @@ impl Rewrite for ast::Expr {
                 }
             }
             ast::Expr_::ExprCall(ref callee, ref args) => {
-                rewrite_call(context, &**callee, args, self.span, width, offset)
+                let inner_span = mk_sp(callee.span.hi, self.span.hi);
+                rewrite_call(context, &**callee, args, inner_span, width, offset)
             }
             ast::Expr_::ExprParen(ref subexpr) => {
                 rewrite_paren(context, subexpr, width, offset)
diff --git a/tests/source/closure.rs b/tests/source/closure.rs
index 43ec6860243..6abd7f9c0a7 100644
--- a/tests/source/closure.rs
+++ b/tests/source/closure.rs
@@ -44,3 +44,9 @@ fn main() {
     |arg1, arg2, _, _, arg3, arg4| { let temp = arg4 + arg3;
                                      arg2 * arg1 - temp }
 }
+
+fn issue311() {
+    let func = |x| println!("{}", x);
+
+    (func)(0.0);
+}
diff --git a/tests/target/closure.rs b/tests/target/closure.rs
index b42296487be..146d967c8d5 100644
--- a/tests/target/closure.rs
+++ b/tests/target/closure.rs
@@ -70,3 +70,9 @@ fn main() {
         arg2 * arg1 - temp
     }
 }
+
+fn issue311() {
+    let func = |x| println!("{}", x);
+
+    (func)(0.0);
+}