about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2012-07-03 01:30:50 +0100
committerBrian Anderson <banderson@mozilla.com>2012-07-02 17:33:57 -0700
commit5bd9d6e05c57d1d3821eb94afcd776b992d1a2d4 (patch)
tree33f8c505ddd15afdc895aba310cae380cab6725e
parent1bd4e35dd8669925d1783ff182f2a470e2a64ad0 (diff)
downloadrust-5bd9d6e05c57d1d3821eb94afcd776b992d1a2d4.tar.gz
rust-5bd9d6e05c57d1d3821eb94afcd776b992d1a2d4.zip
Implemented better error message for missing do statements.
This fixes #2783 for the case where an empty double pipe
symbol is being used without a do keyword.
-rw-r--r--src/rustc/middle/typeck/check.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs
index aac959b4cb4..ef0815927e4 100644
--- a/src/rustc/middle/typeck/check.rs
+++ b/src/rustc/middle/typeck/check.rs
@@ -973,11 +973,25 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
           _ {}
         }
         check_expr(fcx, rhs, none);
+
         tcx.sess.span_err(
             ex.span, "binary operation " + ast_util::binop_to_str(op) +
             " cannot be applied to type `" +
             fcx.infcx.ty_to_str(lhs_resolved_t) +
             "`");
+
+        // If the or operator is used it might be that the user forgot to
+        // supply the do keyword.  Let's be more helpful in that situation.
+        if op == ast::or {
+          alt ty::get(lhs_resolved_t).struct {
+            ty::ty_fn(f) {
+              tcx.sess.span_note(
+                  ex.span, "did you forget the 'do' keyword for the call?");
+            }
+            _ {}
+          }
+        }
+
         (lhs_resolved_t, false)
     }
     fn check_user_unop(fcx: @fn_ctxt, op_str: str, mname: str,