]> git.lizzy.rs Git - rust.git/commitdiff
update to new error format E0409
authorMikhail Modin <mikhailm1@gmail.com>
Tue, 16 Aug 2016 19:13:09 +0000 (22:13 +0300)
committerMikhail Modin <mikhailm1@gmail.com>
Tue, 16 Aug 2016 19:13:09 +0000 (22:13 +0300)
src/librustc_resolve/lib.rs
src/test/compile-fail/E0409.rs

index 962509be324de363aa44c8e3bce6f87c3033b804..a736067be6b7d92e1c6aa457a44421df722eabe2 100644 (file)
@@ -117,7 +117,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
@@ -270,14 +270,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,
@@ -2044,8 +2049,10 @@ fn check_consistent_bindings(&mut self, arm: &Arm) {
                         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));
                         }
                     }
                 }
index 366ad152072508bca919ad07ae7d1c3b65dfd5fa..e89cc9ea5cbf26b19a7df4503d1a9f318ced1980 100644 (file)
@@ -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}`
         _ => ()
     }
 }