about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-05 16:13:00 +0200
committerGitHub <noreply@github.com>2016-08-05 16:13:00 +0200
commitdbef510f3c845606e9388b2d4c6a96ba5c35a1d6 (patch)
tree0507af633af5c59f61c317cb1c756610f8a8f54c
parent0339904fb479898ec3f2e9521c3398aac5ac8f79 (diff)
parent1ca95ae5ba9c0b3974b620399297c3d494d73601 (diff)
Rollup merge of #35350 - birryree:E0368_update, r=jonathandturner
Fix for issue #35336 - updating error message for for E0368 to includ…

…e a span_label.

This fixes #35336 as part of #35233

r? @jonathandturner
-rw-r--r--src/librustc_typeck/check/op.rs14
-rw-r--r--src/test/compile-fail/issue-5239-1.rs1
2 files changed, 10 insertions, 5 deletions
diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs
index d02f87d0b9c..63487683ec3 100644
--- a/src/librustc_typeck/check/op.rs
+++ b/src/librustc_typeck/check/op.rs
@@ -176,11 +176,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 // error types are considered "builtin"
                 if !lhs_ty.references_error() {
                     if let IsAssign::Yes = is_assign {
-                        span_err!(self.tcx.sess, lhs_expr.span, E0368,
-                                  "binary assignment operation `{}=` \
-                                   cannot be applied to type `{}`",
-                                  op.node.as_str(),
-                                  lhs_ty);
+                        struct_span_err!(self.tcx.sess, lhs_expr.span, E0368,
+                                         "binary assignment operation `{}=` \
+                                          cannot be applied to type `{}`",
+                                         op.node.as_str(),
+                                         lhs_ty)
+                            .span_label(lhs_expr.span,
+                                        &format!("cannot use `{}=` on type `{}`",
+                                        op.node.as_str(), lhs_ty))
+                            .emit();
                     } else {
                         let mut err = struct_span_err!(self.tcx.sess, lhs_expr.span, E0369,
                             "binary operation `{}` cannot be applied to type `{}`",
diff --git a/src/test/compile-fail/issue-5239-1.rs b/src/test/compile-fail/issue-5239-1.rs
index 1ebef06008f..06e3c9a207b 100644
--- a/src/test/compile-fail/issue-5239-1.rs
+++ b/src/test/compile-fail/issue-5239-1.rs
@@ -13,4 +13,5 @@
 fn main() {
     let x = |ref x: isize| -> isize { x += 1; };
     //~^ ERROR E0368
+    //~| NOTE cannot use `+=` on type `&isize`
 }