about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonathan Turner <jonathandturner@users.noreply.github.com>2016-08-17 06:25:28 -0700
committerGitHub <noreply@github.com>2016-08-17 06:25:28 -0700
commitfbc62afba63dc2431c98c881403a53f0ccce1d0a (patch)
tree24d42f211b90c567de6805e6f62191a61c2f8e2a
parente20a7e34183d7bed79b58d0cb4e330917d96e48d (diff)
parent193b9ae86b7ba498430866fb6090617194ba5ed7 (diff)
downloadrust-fbc62afba63dc2431c98c881403a53f0ccce1d0a.tar.gz
rust-fbc62afba63dc2431c98c881403a53f0ccce1d0a.zip
Rollup merge of #35726 - mikhail-m1:master2, r=jonathandturner
update E0409 to new error format

fixes #35699 as part of #35233.

r? @jonathandturner
-rw-r--r--src/librustc_resolve/lib.rs19
-rw-r--r--src/test/compile-fail/E0409.rs7
2 files changed, 19 insertions, 7 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 8b06bae6e84..d90a932a63d 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -116,7 +116,7 @@ enum ResolutionError<'a> {
     /// error E0408: variable `{}` from pattern #{} is not bound in pattern #{}
     VariableNotBoundInPattern(Name, usize, usize),
     /// error E0409: variable is bound with different mode in pattern #{} than in pattern #1
-    VariableBoundWithDifferentMode(Name, usize),
+    VariableBoundWithDifferentMode(Name, usize, Span),
     /// error E0411: use of `Self` outside of an impl or trait
     SelfUsedOutsideImplOrTrait,
     /// error E0412: use of undeclared
@@ -269,14 +269,19 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
                              from,
                              to)
         }
-        ResolutionError::VariableBoundWithDifferentMode(variable_name, pattern_number) => {
-            struct_span_err!(resolver.session,
+        ResolutionError::VariableBoundWithDifferentMode(variable_name,
+                                                        pattern_number,
+                                                        first_binding_span) => {
+            let mut err = struct_span_err!(resolver.session,
                              span,
                              E0409,
                              "variable `{}` is bound with different mode in pattern #{} than in \
                               pattern #1",
                              variable_name,
-                             pattern_number)
+                             pattern_number);
+            err.span_label(span, &format!("bound in different ways"));
+            err.span_label(first_binding_span, &format!("first binding"));
+            err
         }
         ResolutionError::SelfUsedOutsideImplOrTrait => {
             let mut err = struct_span_err!(resolver.session,
@@ -2030,8 +2035,10 @@ impl<'a> Resolver<'a> {
                         if binding_0.binding_mode != binding_i.binding_mode {
                             resolve_error(self,
                                           binding_i.span,
-                                          ResolutionError::VariableBoundWithDifferentMode(key.name,
-                                                                                          i + 1));
+                                          ResolutionError::VariableBoundWithDifferentMode(
+                                              key.name,
+                                              i + 1,
+                                              binding_0.span));
                         }
                     }
                 }
diff --git a/src/test/compile-fail/E0409.rs b/src/test/compile-fail/E0409.rs
index 366ad152072..e89cc9ea5cb 100644
--- a/src/test/compile-fail/E0409.rs
+++ b/src/test/compile-fail/E0409.rs
@@ -13,7 +13,12 @@ fn main() {
 
     match x {
         (0, ref y) | (y, 0) => {} //~ ERROR E0409
-                                  //~^ ERROR E0308
+                                  //~^ NOTE bound in different ways
+                                  //~| NOTE first binding
+                                  //~| ERROR E0308
+                                  //~| NOTE expected &{integer}, found integral variable
+                                  //~| NOTE expected type `&{integer}`
+                                  //~| NOTE    found type `{integer}`
         _ => ()
     }
 }