about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVishnunarayan K I <appukuttancr@gmail.com>2020-11-03 12:15:41 +0530
committerVishnunarayan K I <appukuttancr@gmail.com>2020-11-03 12:15:41 +0530
commitf422e811e4932907e11e8da92f24d2834f7612f2 (patch)
tree6408ccd8eb5e43395ea15fa8f31a3a741076f31d
parent6bdce7bedd765438ce4f138cb0ce9335659e32d6 (diff)
downloadrust-f422e811e4932907e11e8da92f24d2834f7612f2.tar.gz
rust-f422e811e4932907e11e8da92f24d2834f7612f2.zip
preserve bindings order for Some
-rw-r--r--compiler/rustc_mir_build/src/build/matches/simplify.rs33
-rw-r--r--src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff6
-rw-r--r--src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff6
-rw-r--r--src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff12
-rw-r--r--src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff40
-rw-r--r--src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff24
-rw-r--r--src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff6
-rw-r--r--src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff6
-rw-r--r--src/test/ui/issues/issue-12567.stderr4
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs4
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr36
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs7
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr75
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs3
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr61
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs10
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr104
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs6
-rw-r--r--src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr54
19 files changed, 239 insertions, 258 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs
index 278d7a6374d..e5fee5df06a 100644
--- a/compiler/rustc_mir_build/src/build/matches/simplify.rs
+++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs
@@ -45,6 +45,26 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     ) -> bool {
         // repeatedly simplify match pairs until fixed point is reached
         debug!("simplify_candidate(candidate={:?})", candidate);
+
+        // exisiting_bindings and new_bindings exists to keep the semantics in order
+        // reversing the binding order for bindings after `@` change binding order in places
+        // it shouldn't be changed, for example `let (Some(a), Some(b)) = (x, y)`
+        //
+        // To avoid this, the binding occurs in the following manner:
+        // * the bindings for one iteration of the following loop occurs in order (i.e. left to
+        // right)
+        // * the bindings from the previous iteration of the loop is prepended to the bindings from
+        // the current iteration (in the implementation this is done by mem::swap and extend)
+        // * after all iterations, these new bindings are then appended to the bindings that were
+        // prexisting (i.e. `candidate.binding` when the function was called).
+        //
+        // example:
+        // candidate.bindings = [1, 2, 3]
+        // binding in iter 1: [4, 5]
+        // binding in iter 2: [6, 7]
+        //
+        // final binding: [1, 2, 3, 6, 7, 4, 5]
+        let mut exisiting_bindings = mem::take(&mut candidate.bindings);
         let mut new_bindings = Vec::new();
         loop {
             let match_pairs = mem::take(&mut candidate.match_pairs);
@@ -52,13 +72,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             if let [MatchPair { pattern: Pat { kind: box PatKind::Or { pats }, .. }, place }] =
                 *match_pairs
             {
+                exisiting_bindings.extend_from_slice(&new_bindings);
+                mem::swap(&mut candidate.bindings, &mut exisiting_bindings);
                 candidate.subcandidates = self.create_or_subcandidates(candidate, place, pats);
                 return true;
             }
 
             let mut changed = false;
             for match_pair in match_pairs {
-                match self.simplify_match_pair(match_pair, candidate, &mut new_bindings) {
+                match self.simplify_match_pair(match_pair, candidate) {
                     Ok(()) => {
                         changed = true;
                     }
@@ -80,11 +102,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             //     let z = x.copy_field;
             //     let y = x;
             // }
-            new_bindings.extend_from_slice(&candidate.bindings);
+            candidate.bindings.extend_from_slice(&new_bindings);
             mem::swap(&mut candidate.bindings, &mut new_bindings);
-            new_bindings.clear();
+            candidate.bindings.clear();
 
             if !changed {
+                exisiting_bindings.extend_from_slice(&new_bindings);
+                mem::swap(&mut candidate.bindings, &mut exisiting_bindings);
                 // Move or-patterns to the end, because they can result in us
                 // creating additional candidates, so we want to test them as
                 // late as possible.
@@ -124,7 +148,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         &mut self,
         match_pair: MatchPair<'pat, 'tcx>,
         candidate: &mut Candidate<'pat, 'tcx>,
-        bindings: &mut Vec<Binding<'tcx>>,
     ) -> Result<(), MatchPair<'pat, 'tcx>> {
         let tcx = self.hir.tcx();
         match *match_pair.pattern.kind {
@@ -152,7 +175,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             }
 
             PatKind::Binding { name, mutability, mode, var, ty, ref subpattern, is_primary: _ } => {
-                bindings.push(Binding {
+                candidate.bindings.push(Binding {
                     name,
                     mutability,
                     span: match_pair.pattern.span,
diff --git a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
index c897aff936c..386726bfddc 100644
--- a/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
+++ b/src/test/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
@@ -52,13 +52,13 @@
 -     }
 - 
 -     bb3: {
-          StorageLive(_9);                 // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25
-          _9 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25
           StorageLive(_8);                 // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16
           _8 = (((_3.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:15: 5:16
+          StorageLive(_9);                 // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25
+          _9 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:5:24: 5:25
           _0 = const 0_u32;                // scope 1 at $DIR/early_otherwise_branch.rs:5:31: 5:32
-          StorageDead(_8);                 // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32
           StorageDead(_9);                 // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32
+          StorageDead(_8);                 // scope 0 at $DIR/early_otherwise_branch.rs:5:31: 5:32
 -         goto -> bb4;                     // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 7:6
 +         goto -> bb3;                     // scope 0 at $DIR/early_otherwise_branch.rs:4:5: 7:6
       }
diff --git a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
index 4ab7b8aed16..bc5934dec84 100644
--- a/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
+++ b/src/test/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
@@ -59,13 +59,13 @@
 - 
 -     bb4: {
 +     bb2: {
-          StorageLive(_10);                // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25
-          _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25
           StorageLive(_9);                 // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16
           _9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:15: 13:16
+          StorageLive(_10);                // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25
+          _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch.rs:13:24: 13:25
           _0 = const 0_u32;                // scope 1 at $DIR/early_otherwise_branch.rs:13:31: 13:32
-          StorageDead(_9);                 // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32
           StorageDead(_10);                // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32
+          StorageDead(_9);                 // scope 0 at $DIR/early_otherwise_branch.rs:13:31: 13:32
 -         goto -> bb6;                     // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 16:6
 +         goto -> bb4;                     // scope 0 at $DIR/early_otherwise_branch.rs:12:5: 16:6
       }
diff --git a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
index 58a7c4a841a..b0357f1aecd 100644
--- a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
+++ b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
@@ -71,16 +71,16 @@
   
 -     bb4: {
 +     bb3: {
-          StorageLive(_13);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34
-          _13 = (((_4.2: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34
-          StorageLive(_12);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25
-          _12 = (((_4.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25
           StorageLive(_11);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16
           _11 = (((_4.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:15: 6:16
+          StorageLive(_12);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25
+          _12 = (((_4.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:24: 6:25
+          StorageLive(_13);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34
+          _13 = (((_4.2: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:33: 6:34
           _0 = const 0_u32;                // scope 1 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41
-          StorageDead(_11);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41
-          StorageDead(_12);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41
           StorageDead(_13);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41
+          StorageDead(_12);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41
+          StorageDead(_11);                // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:6:40: 6:41
 -         goto -> bb5;                     // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 8:6
 +         goto -> bb4;                     // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:5:5: 8:6
       }
diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff
index 963f7ffc920..f51a08ed730 100644
--- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff
+++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff
@@ -109,10 +109,10 @@
       }
   
 +     bb2: {
-+         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
-+         _16 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
 +         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17
 +         _15 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17
++         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
++         _16 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
 +         nop;                             // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49
 +         nop;                             // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41
 +         nop;                             // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41
@@ -132,10 +132,10 @@
       bb3: {
 -         _8 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:21: 24:30
 -         switchInt(move _8) -> [1_isize: bb7, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:21: 24:30
-+         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
-+         _21 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
 +         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17
 +         _20 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17
++         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
++         _21 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
 +         nop;                             // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49
 +         nop;                             // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41
 +         nop;                             // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41
@@ -155,10 +155,10 @@
       bb4: {
 -         _9 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:23: 25:34
 -         switchInt(move _9) -> [2_isize: bb8, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:23: 25:34
-+         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
-+         _26 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
 +         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
 +         _25 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
++         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
++         _26 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
 +         nop;                             // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55
 +         nop;                             // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47
 +         nop;                             // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47
@@ -178,10 +178,10 @@
       bb5: {
 -         _10 = discriminant((*(_4.1: &ViewportPercentageLength))); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:23: 26:34
 -         switchInt(move _10) -> [3_isize: bb9, otherwise: bb2]; // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:23: 26:34
-+         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
-+         _31 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
 +         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19
 +         _30 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19
++         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
++         _31 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
 +         nop;                             // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55
 +         nop;                             // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47
 +         nop;                             // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47
@@ -199,10 +199,10 @@
       }
   
       bb6: {
--         StorageLive(_13);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
--         _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
 -         StorageLive(_12);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17
 -         _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17
+-         StorageLive(_13);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
+-         _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
 -         StorageLive(_14);                // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49
 -         StorageLive(_15);                // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41
 -         _15 = _12;                       // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41
@@ -214,8 +214,8 @@
 -         ((_3 as Vw).0: f32) = move _14;  // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50
 -         discriminant(_3) = 0;            // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50
 -         StorageDead(_14);                // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
--         StorageDead(_12);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
 -         StorageDead(_13);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
+-         StorageDead(_12);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 +         nop;                             // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
 +         discriminant(_0) = 0;            // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:5: 28:7
@@ -225,10 +225,10 @@
       }
   
       bb7: {
--         StorageLive(_18);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
--         _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
 -         StorageLive(_17);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17
 -         _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17
+-         StorageLive(_18);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
+-         _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
 -         StorageLive(_19);                // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49
 -         StorageLive(_20);                // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41
 -         _20 = _17;                       // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41
@@ -240,16 +240,16 @@
 -         ((_3 as Vh).0: f32) = move _19;  // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50
 -         discriminant(_3) = 1;            // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50
 -         StorageDead(_19);                // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
--         StorageDead(_17);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
 -         StorageDead(_18);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
+-         StorageDead(_17);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 -     }
 - 
 -     bb8: {
--         StorageLive(_23);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
--         _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
 -         StorageLive(_22);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
 -         _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
+-         StorageLive(_23);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
+-         _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
 -         StorageLive(_24);                // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55
 -         StorageLive(_25);                // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47
 -         _25 = _22;                       // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47
@@ -261,16 +261,16 @@
 -         ((_3 as Vmin).0: f32) = move _24; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56
 -         discriminant(_3) = 2;            // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56
 -         StorageDead(_24);                // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
--         StorageDead(_22);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
 -         StorageDead(_23);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
+-         StorageDead(_22);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 -     }
 - 
 -     bb9: {
--         StorageLive(_28);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
--         _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
 -         StorageLive(_27);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19
 -         _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19
+-         StorageLive(_28);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
+-         _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
 -         StorageLive(_29);                // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55
 -         StorageLive(_30);                // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47
 -         _30 = _27;                       // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47
@@ -282,8 +282,8 @@
 -         ((_3 as Vmax).0: f32) = move _29; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56
 -         discriminant(_3) = 3;            // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56
 -         StorageDead(_29);                // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
--         StorageDead(_27);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
 -         StorageDead(_28);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
+-         StorageDead(_27);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 -     }
 - 
diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
index fcfa8fcb257..05ef6721e65 100644
--- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
+++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
@@ -109,10 +109,10 @@
 - 
 -     bb6: {
 +     bb2: {
-          StorageLive(_13);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
-          _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
           StorageLive(_12);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17
           _12 = (((*(_4.0: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:14: 23:17
+          StorageLive(_13);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
+          _13 = (((*(_4.1: &ViewportPercentageLength)) as Vw).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:24: 23:29
           StorageLive(_14);                // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:49
           StorageLive(_15);                // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41
           _15 = _12;                       // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:38: 23:41
@@ -124,18 +124,18 @@
           ((_3 as Vw).0: f32) = move _14;  // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50
           discriminant(_3) = 0;            // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:35: 23:50
           StorageDead(_14);                // scope 1 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
-          StorageDead(_12);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
           StorageDead(_13);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
+          StorageDead(_12);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:23:49: 23:50
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 +         goto -> bb6;                     // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
       }
   
 -     bb7: {
 +     bb3: {
-          StorageLive(_18);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
-          _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
           StorageLive(_17);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17
           _17 = (((*(_4.0: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:14: 24:17
+          StorageLive(_18);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
+          _18 = (((*(_4.1: &ViewportPercentageLength)) as Vh).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:24: 24:29
           StorageLive(_19);                // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:49
           StorageLive(_20);                // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41
           _20 = _17;                       // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:38: 24:41
@@ -147,18 +147,18 @@
           ((_3 as Vh).0: f32) = move _19;  // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50
           discriminant(_3) = 1;            // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:35: 24:50
           StorageDead(_19);                // scope 2 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
-          StorageDead(_17);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
           StorageDead(_18);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
+          StorageDead(_17);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:24:49: 24:50
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 +         goto -> bb6;                     // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
       }
   
 -     bb8: {
 +     bb4: {
-          StorageLive(_23);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
-          _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
           StorageLive(_22);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
           _22 = (((*(_4.0: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:16: 25:19
+          StorageLive(_23);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
+          _23 = (((*(_4.1: &ViewportPercentageLength)) as Vmin).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:28: 25:33
           StorageLive(_24);                // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:55
           StorageLive(_25);                // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47
           _25 = _22;                       // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:44: 25:47
@@ -170,18 +170,18 @@
           ((_3 as Vmin).0: f32) = move _24; // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56
           discriminant(_3) = 2;            // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:39: 25:56
           StorageDead(_24);                // scope 3 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
-          StorageDead(_22);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
           StorageDead(_23);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
+          StorageDead(_22);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:25:55: 25:56
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 +         goto -> bb6;                     // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
       }
   
 -     bb9: {
 +     bb5: {
-          StorageLive(_28);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
-          _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
           StorageLive(_27);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19
           _27 = (((*(_4.0: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:16: 26:19
+          StorageLive(_28);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
+          _28 = (((*(_4.1: &ViewportPercentageLength)) as Vmax).0: f32); // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:28: 26:33
           StorageLive(_29);                // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:55
           StorageLive(_30);                // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47
           _30 = _27;                       // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:44: 26:47
@@ -193,8 +193,8 @@
           ((_3 as Vmax).0: f32) = move _29; // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56
           discriminant(_3) = 3;            // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:39: 26:56
           StorageDead(_29);                // scope 4 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
-          StorageDead(_27);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
           StorageDead(_28);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
+          StorageDead(_27);                // scope 0 at $DIR/early_otherwise_branch_68867.rs:26:55: 26:56
 -         goto -> bb10;                    // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
 +         goto -> bb6;                     // scope 0 at $DIR/early_otherwise_branch_68867.rs:22:8: 28:6
       }
diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
index 6703bc58c32..9a6094f12df 100644
--- a/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
+++ b/src/test/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
@@ -56,13 +56,13 @@
       }
   
       bb4: {
-          StorageLive(_10);                // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25
-          _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25
           StorageLive(_9);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16
           _9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:15: 9:16
+          StorageLive(_10);                // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25
+          _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:24: 9:25
           _0 = const 0_u32;                // scope 1 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
-          StorageDead(_9);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
           StorageDead(_10);                // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
+          StorageDead(_9);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:9:31: 9:32
           goto -> bb7;                     // scope 0 at $DIR/early_otherwise_branch_noopt.rs:8:5: 13:6
       }
   
diff --git a/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff
index 9efb2239e40..c3aecb45293 100644
--- a/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff
+++ b/src/test/mir-opt/early_otherwise_branch_noopt.noopt2.EarlyOtherwiseBranch.diff
@@ -42,13 +42,13 @@
       }
   
       bb3: {
-          StorageLive(_9);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25
-          _9 = (((_3.1: std::option::Option<bool>) as Some).0: bool); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25
           StorageLive(_8);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16
           _8 = (((_3.0: std::option::Option<u32>) as Some).0: u32); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:15: 20:16
+          StorageLive(_9);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25
+          _9 = (((_3.1: std::option::Option<bool>) as Some).0: bool); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:24: 20:25
           _0 = const 0_u32;                // scope 1 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32
-          StorageDead(_8);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32
           StorageDead(_9);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32
+          StorageDead(_8);                 // scope 0 at $DIR/early_otherwise_branch_noopt.rs:20:31: 20:32
           goto -> bb4;                     // scope 0 at $DIR/early_otherwise_branch_noopt.rs:19:5: 22:6
       }
   
diff --git a/src/test/ui/issues/issue-12567.stderr b/src/test/ui/issues/issue-12567.stderr
index 2a88d8f0524..3ce659ccd14 100644
--- a/src/test/ui/issues/issue-12567.stderr
+++ b/src/test/ui/issues/issue-12567.stderr
@@ -8,7 +8,7 @@ LL |         (&[], &[hd, ..]) | (&[hd, ..], &[])
    |                 -- data moved here
 LL |             => println!("one empty"),
 LL |         (&[hd1, ..], &[hd2, ..])
-   |                        --- ...and here
+   |            --- ...and here
    |
    = note: move occurs because these variables have types that don't implement the `Copy` trait
 
@@ -22,7 +22,7 @@ LL |         (&[], &[hd, ..]) | (&[hd, ..], &[])
    |                 -- data moved here
 LL |             => println!("one empty"),
 LL |         (&[hd1, ..], &[hd2, ..])
-   |            --- ...and here
+   |                        --- ...and here
    |
    = note: move occurs because these variables have types that don't implement the `Copy` trait
 
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs
index 83f9b82b242..bce43f9df85 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.rs
@@ -17,8 +17,8 @@ fn main() {
     let a @ (b, c) = (u(), u()); //~ ERROR use of partially moved value
 
     match Ok(U) {
-        a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of partially moved value
-                                     //~^ ERROR use of partially moved value
+        a @ Ok(b) | a @ Err(b) => {} //~ ERROR use of moved value
+                                     //~^ ERROR use of moved value
     }
 
     fn fun(a @ b: U) {} //~ ERROR use of moved value
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr
index 482ebd9b423..bfb7b479731 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr
@@ -29,35 +29,27 @@ LL |     let a @ (b, c) = (u(), u());
    |
    = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
 
-error[E0382]: use of partially moved value
-  --> $DIR/borrowck-move-and-move.rs:20:9
+error[E0382]: use of moved value
+  --> $DIR/borrowck-move-and-move.rs:20:16
    |
+LL |     match Ok(U) {
+   |           ----- move occurs because value has type `std::result::Result<U, U>`, which does not implement the `Copy` trait
 LL |         a @ Ok(b) | a @ Err(b) => {}
-   |         ^^^^^^^-^
+   |         -------^-
    |         |      |
-   |         |      value partially moved here
-   |         value used here after partial move
-   |
-   = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving the value
-   |
-LL |         a @ Ok(ref b) | a @ Err(b) => {}
-   |                ^^^
+   |         |      value used here after move
+   |         value moved here
 
-error[E0382]: use of partially moved value
-  --> $DIR/borrowck-move-and-move.rs:20:21
+error[E0382]: use of moved value
+  --> $DIR/borrowck-move-and-move.rs:20:29
    |
+LL |     match Ok(U) {
+   |           ----- move occurs because value has type `std::result::Result<U, U>`, which does not implement the `Copy` trait
 LL |         a @ Ok(b) | a @ Err(b) => {}
-   |                     ^^^^^^^^-^
+   |                     --------^-
    |                     |       |
-   |                     |       value partially moved here
-   |                     value used here after partial move
-   |
-   = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving the value
-   |
-LL |         a @ Ok(b) | a @ Err(ref b) => {}
-   |                             ^^^
+   |                     |       value used here after move
+   |                     value moved here
 
 error[E0382]: use of partially moved value
   --> $DIR/borrowck-move-and-move.rs:27:9
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs
index e75ff78abd7..8a574f880ed 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.rs
@@ -50,17 +50,19 @@ fn main() {
         //~^ ERROR borrow of moved value
         //~| ERROR borrow of moved value
         //~| ERROR borrow of moved value
-        //~| ERROR use of partially moved value
+        //~| ERROR use of moved value
         None => {}
     }
     match Some([U, U]) {
         mut a @ Some([ref b, ref mut c]) => {}
         //~^ ERROR borrow of moved value
+        //~| ERROR borrow of moved value
         None => {}
     }
     match Some(u()) {
         a @ Some(ref b) => {}
         //~^ ERROR borrow of moved value
+        //~| ERROR borrow of moved value
         None => {}
     }
     match Some((u(), u())) {
@@ -68,12 +70,13 @@ fn main() {
         //~^ ERROR borrow of moved value
         //~| ERROR borrow of moved value
         //~| ERROR borrow of moved value
-        //~| ERROR use of partially moved value
+        //~| ERROR use of moved value
         None => {}
     }
     match Some([u(), u()]) {
         mut a @ Some([ref b, ref mut c]) => {}
         //~^ ERROR borrow of moved value
+        //~| ERROR borrow of moved value
         None => {}
     }
 }
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr
index c1ea5d8ec6d..79addf9d574 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr
@@ -155,7 +155,7 @@ LL |         mut a @ Some([ref b, ref mut c]) => {}
    |         move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait
 
 error: borrow of moved value
-  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:62:9
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:9
    |
 LL |         a @ Some(ref b) => {}
    |         -^^^^^^^^-----^
@@ -165,7 +165,7 @@ LL |         a @ Some(ref b) => {}
    |         move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait
 
 error: borrow of moved value
-  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:9
    |
 LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
    |         -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^
@@ -176,7 +176,7 @@ LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
    |         move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait
 
 error: borrow of moved value
-  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:19
    |
 LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
    |                   -----^^^---------
@@ -186,7 +186,7 @@ LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
    |                   move occurs because `b` has type `U` which does not implement the `Copy` trait
 
 error: borrow of moved value
-  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38
    |
 LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
    |                                      -^^^-----
@@ -196,7 +196,7 @@ LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
    |                                      move occurs because `d` has type `U` which does not implement the `Copy` trait
 
 error: borrow of moved value
-  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:9
    |
 LL |         mut a @ Some([ref b, ref mut c]) => {}
    |         -----^^^^^^^^^-----^^---------^^
@@ -280,35 +280,60 @@ LL |     let a @ (mut b @ ref mut c, d @ ref e) = (u(), u());
    |
    = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
 
-error[E0382]: use of partially moved value
-  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:9
+error[E0382]: use of moved value
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:49:38
    |
+LL |     match Some((U, U)) {
+   |           ------------ move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait
 LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^
+   |         -----------------------------^^^^^^^^^--
    |         |                            |
-   |         |                            value partially moved here
-   |         value used here after partial move
+   |         |                            value used here after move
+   |         value moved here
+
+error[E0382]: borrow of moved value
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:57:30
    |
-   = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving the value
+LL |     match Some([U, U]) {
+   |           ------------ move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait
+LL |         mut a @ Some([ref b, ref mut c]) => {}
+   |         ---------------------^^^^^^^^^--
+   |         |                    |
+   |         |                    value borrowed here after move
+   |         value moved here
+
+error[E0382]: borrow of moved value
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:63:18
    |
-LL |         a @ Some((mut b @ ref mut c, ref d @ ref e)) => {}
-   |                                      ^^^
+LL |     match Some(u()) {
+   |           --------- move occurs because value has type `Option<U>`, which does not implement the `Copy` trait
+LL |         a @ Some(ref b) => {}
+   |         ---------^^^^^-
+   |         |        |
+   |         |        value borrowed here after move
+   |         value moved here
 
-error[E0382]: use of partially moved value
-  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9
+error[E0382]: use of moved value
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:69:38
    |
+LL |     match Some((u(), u())) {
+   |           ---------------- move occurs because value has type `Option<(U, U)>`, which does not implement the `Copy` trait
 LL |         a @ Some((mut b @ ref mut c, d @ ref e)) => {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^
+   |         -----------------------------^^^^^^^^^--
    |         |                            |
-   |         |                            value partially moved here
-   |         value used here after partial move
-   |
-   = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving the value
+   |         |                            value used here after move
+   |         value moved here
+
+error[E0382]: borrow of moved value
+  --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:77:30
    |
-LL |         a @ Some((mut b @ ref mut c, ref d @ ref e)) => {}
-   |                                      ^^^
+LL |     match Some([u(), u()]) {
+   |           ---------------- move occurs because value has type `Option<[U; 2]>`, which does not implement the `Copy` trait
+LL |         mut a @ Some([ref b, ref mut c]) => {}
+   |         ---------------------^^^^^^^^^--
+   |         |                    |
+   |         |                    value borrowed here after move
+   |         value moved here
 
 error[E0382]: use of partially moved value
   --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:16:11
@@ -321,6 +346,6 @@ LL |     fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
    |
    = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
 
-error: aborting due to 30 previous errors
+error: aborting due to 33 previous errors
 
 For more information about this error, try `rustc --explain E0382`.
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs
index 691d0a32fa8..b9235eabd88 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.rs
@@ -60,13 +60,11 @@ fn main() {
     match Some([U, U]) {
         ref mut a @ Some([b, mut c]) => {}
         //~^ ERROR cannot move out of value because it is borrowed
-        //~| ERROR borrow of partially moved value
         None => {}
     }
     match Some(u()) {
         ref a @ Some(b) => {}
         //~^ ERROR cannot move out of value because it is borrowed
-        //~| ERROR borrow of partially moved value
         None => {}
     }
     match Some((u(), u())) {
@@ -81,7 +79,6 @@ fn main() {
     match Some([u(), u()]) {
         ref mut a @ Some([b, mut c]) => {}
         //~^ ERROR cannot move out of value because it is borrowed
-        //~| ERROR borrow of partially moved value
         None => {}
     }
 }
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr
index a39ff8774f7..50b2f8929f2 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr
@@ -140,7 +140,7 @@ LL |         ref mut a @ Some([b, mut c]) => {}
    |         value borrowed, by `a`, here
 
 error: cannot move out of value because it is borrowed
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9
+  --> $DIR/borrowck-pat-by-move-and-ref.rs:66:9
    |
 LL |         ref a @ Some(b) => {}
    |         -----^^^^^^^^-^
@@ -149,7 +149,7 @@ LL |         ref a @ Some(b) => {}
    |         value borrowed, by `a`, here
 
 error: cannot move out of value because it is borrowed
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:73:9
+  --> $DIR/borrowck-pat-by-move-and-ref.rs:71:9
    |
 LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |         -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^
@@ -159,7 +159,7 @@ LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |         value borrowed, by `a`, here
 
 error: cannot move out of value because it is borrowed
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23
+  --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23
    |
 LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |                       -----^^^-----
@@ -168,7 +168,7 @@ LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |                       value borrowed, by `b`, here
 
 error: cannot move out of value because it is borrowed
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38
+  --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38
    |
 LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |                                      -----^^^-
@@ -177,7 +177,7 @@ LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |                                      value borrowed, by `d`, here
 
 error: cannot move out of value because it is borrowed
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9
+  --> $DIR/borrowck-pat-by-move-and-ref.rs:80:9
    |
 LL |         ref mut a @ Some([b, mut c]) => {}
    |         ---------^^^^^^^^^-^^-----^^
@@ -286,38 +286,8 @@ LL |     let ref mut a @ [b, mut c] = [u(), u()];
    |
    = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
 
-error[E0382]: borrow of partially moved value
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:61:9
-   |
-LL |         ref mut a @ Some([b, mut c]) => {}
-   |         ^^^^^^^^^^^^^^^^^^^^^-----^^
-   |         |                    |
-   |         |                    value partially moved here
-   |         value borrowed here after partial move
-   |
-   = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving the value
-   |
-LL |         ref mut a @ Some([b, ref mut c]) => {}
-   |                              ^^^
-
-error[E0382]: borrow of partially moved value
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:67:9
-   |
-LL |         ref a @ Some(b) => {}
-   |         ^^^^^^^^^^^^^-^
-   |         |            |
-   |         |            value partially moved here
-   |         value borrowed here after partial move
-   |
-   = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving the value
-   |
-LL |         ref a @ Some(ref b) => {}
-   |                      ^^^
-
 error[E0382]: borrow of moved value
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:73:23
+  --> $DIR/borrowck-pat-by-move-and-ref.rs:71:23
    |
 LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |                       ^^^^^^^^-----
@@ -332,7 +302,7 @@ LL |         ref a @ Some((ref b @ ref mut c, ref d @ e)) => {}
    |                               ^^^
 
 error[E0382]: borrow of moved value
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:73:38
+  --> $DIR/borrowck-pat-by-move-and-ref.rs:71:38
    |
 LL |         ref a @ Some((ref b @ mut c, ref d @ e)) => {}
    |                                      ^^^^^^^^-
@@ -346,21 +316,6 @@ help: borrow this field in the pattern to avoid moving the value
 LL |         ref a @ Some((ref b @ mut c, ref d @ ref e)) => {}
    |                                              ^^^
 
-error[E0382]: borrow of partially moved value
-  --> $DIR/borrowck-pat-by-move-and-ref.rs:82:9
-   |
-LL |         ref mut a @ Some([b, mut c]) => {}
-   |         ^^^^^^^^^^^^^^^^^^^^^-----^^
-   |         |                    |
-   |         |                    value partially moved here
-   |         value borrowed here after partial move
-   |
-   = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
-help: borrow this field in the pattern to avoid moving the value
-   |
-LL |         ref mut a @ Some([b, ref mut c]) => {}
-   |                              ^^^
-
 error[E0382]: borrow of moved value
   --> $DIR/borrowck-pat-by-move-and-ref.rs:13:11
    |
@@ -404,6 +359,6 @@ LL |     fn f3(ref mut a @ [b, mut c]: [U; 2]) {}
    |
    = note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
 
-error: aborting due to 39 previous errors
+error: aborting due to 36 previous errors
 
 For more information about this error, try `rustc --explain E0382`.
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs
index f543eaece80..2d391cd7d07 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.rs
@@ -9,7 +9,7 @@ fn main() {
     match &mut Some(1) {
         ref mut z @ &mut Some(ref a) => {
         //~^ ERROR cannot borrow value as immutable because it is also borrowed as mutable
-        //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
+        //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
             **z = None;
             println!("{}", *a);
         }
@@ -78,8 +78,8 @@ fn main() {
         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
             //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
             //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
-            //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
-            //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
+            //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
+            //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
             *b = U;
             drop(a);
         }
@@ -90,8 +90,6 @@ fn main() {
         //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
         //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
         //~| ERROR cannot assign to `*b`, as it is immutable for the pattern guard
-        //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
-        //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
         _ => {}
     }
     match Ok(U) {
@@ -105,8 +103,6 @@ fn main() {
         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
         //~^ ERROR cannot borrow value as mutable because it is also borrowed as immutable
         //~| ERROR cannot borrow value as mutable because it is also borrowed as immutable
-        //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
-        //~| ERROR cannot borrow value as immutable because it is also borrowed as mutable
         //~| ERROR cannot move out of `b` in pattern guard
         //~| ERROR cannot move out of `b` in pattern guard
         _ => {}
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
index 26182a1bc74..00136c25764 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
@@ -155,7 +155,7 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false }
    |                                 immutable borrow, by `a`, occurs here
 
 error: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:9
    |
 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
    |         ---------^^^^^^-----^
@@ -164,7 +164,7 @@ LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa
    |         mutable borrow, by `a`, occurs here
 
 error: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:33
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:33
    |
 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
    |                                 ---------^^^^^^^-----^
@@ -173,7 +173,7 @@ LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); fa
    |                                 mutable borrow, by `a`, occurs here
 
 error: cannot borrow value as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:9
    |
 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
    |         -----^^^^^^---------^
@@ -182,7 +182,7 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
    |         immutable borrow, by `a`, occurs here
 
 error: cannot borrow value as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:33
    |
 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
    |                                 -----^^^^^^^---------^
@@ -191,7 +191,7 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
    |                                 immutable borrow, by `a`, occurs here
 
 error: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:9
    |
 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
    |         ---------^^^^^^-----^
@@ -200,7 +200,7 @@ LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
    |         mutable borrow, by `a`, occurs here
 
 error: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:33
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:33
    |
 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
    |                                 ---------^^^^^^^-----^
@@ -209,7 +209,7 @@ LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
    |                                 mutable borrow, by `a`, occurs here
 
 error: cannot borrow value as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9
    |
 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         -----^^^^---------^^---------^
@@ -219,7 +219,7 @@ LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         immutable borrow, by `a`, occurs here
 
 error: cannot borrow value as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9
    |
 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         -----^^^^---------^^---------^
@@ -229,7 +229,7 @@ LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         immutable borrow, by `a`, occurs here
 
 error: cannot borrow value as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9
    |
 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         -----^^^^---------^^---------^
@@ -239,7 +239,7 @@ LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         immutable borrow, by `a`, occurs here
 
 error: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:140:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:136:9
    |
 LL |     let ref mut a @ (ref b, ref c) = (U, U);
    |         ---------^^^^-----^^-----^
@@ -294,17 +294,17 @@ LL |     fn f4_also_moved(ref a @ ref mut b @ c: U) {}
    |                              |           value moved into `c` here
    |                              value borrowed, by `b`, here
 
-error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:9
+error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:31
    |
 LL |         ref mut z @ &mut Some(ref a) => {
-   |         ^^^^^^^^^^^^^^^^^^^^^^-----^
+   |         ----------------------^^^^^-
    |         |                     |
    |         |                     immutable borrow occurs here
    |         mutable borrow occurs here
 ...
-LL |             println!("{}", *a);
-   |                            -- immutable borrow later used here
+LL |             **z = None;
+   |             ---------- mutable borrow later used here
 
 error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:48:9
@@ -330,47 +330,29 @@ LL |     let ref a @ ref mut b = u();
 LL |     *b = u();
    |     -------- mutable borrow later used here
 
-error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:9
+error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:20
    |
 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
-   |         ^^^^^^^^^^^---------^
+   |         -----------^^^^^^^^^-
    |         |          |
    |         |          mutable borrow occurs here
    |         immutable borrow occurs here
 ...
-LL |             *b = U;
-   |             ------ mutable borrow later used here
+LL |             drop(a);
+   |                  - immutable borrow later used here
 
-error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:33
+error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:78:45
    |
 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
-   |                                 ^^^^^^^^^^^^---------^
+   |                                 ------------^^^^^^^^^-
    |                                 |           |
    |                                 |           mutable borrow occurs here
    |                                 immutable borrow occurs here
 ...
-LL |             *b = U;
-   |             ------ mutable borrow later used here
-
-error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:9
-   |
-LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
-   |         ^^^^^^^^^^^---------^                               ------ mutable borrow later used here
-   |         |          |
-   |         |          mutable borrow occurs here
-   |         immutable borrow occurs here
-
-error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:33
-   |
-LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
-   |                                 ^^^^^^^^^^^^---------^      ------ mutable borrow later used here
-   |                                 |           |
-   |                                 |           mutable borrow occurs here
-   |                                 immutable borrow occurs here
+LL |             drop(a);
+   |                  - immutable borrow later used here
 
 error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard
   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:89:61
@@ -381,33 +363,15 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false }
    = note: variables bound in patterns are immutable until the end of the pattern guard
 
 error[E0594]: cannot assign to `*a`, as it is immutable for the pattern guard
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:98:61
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:96:61
    |
 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
    |                                                             ^^^^^^^^^^^ cannot assign
    |
    = note: variables bound in patterns are immutable until the end of the pattern guard
 
-error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:9
-   |
-LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
-   |         ^^^^^^^^^^^---------^                                    - mutable borrow later used here
-   |         |          |
-   |         |          mutable borrow occurs here
-   |         immutable borrow occurs here
-
-error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:33
-   |
-LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
-   |                                 ^^^^^^^^^^^^---------^           - mutable borrow later used here
-   |                                 |           |
-   |                                 |           mutable borrow occurs here
-   |                                 immutable borrow occurs here
-
 error[E0507]: cannot move out of `b` in pattern guard
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66
    |
 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
    |                                                                  ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait
@@ -415,7 +379,7 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
 
 error[E0507]: cannot move out of `b` in pattern guard
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:105:66
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:103:66
    |
 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
    |                                                                  ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait
@@ -423,7 +387,7 @@ LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
 
 error[E0507]: cannot move out of `a` in pattern guard
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66
    |
 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
    |                                                                  ^ move occurs because `a` has type `&mut std::result::Result<U, U>`, which does not implement the `Copy` trait
@@ -431,7 +395,7 @@ LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
 
 error[E0507]: cannot move out of `a` in pattern guard
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:66
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66
    |
 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
    |                                                                  ^ move occurs because `a` has type `&mut std::result::Result<U, U>`, which does not implement the `Copy` trait
@@ -439,7 +403,7 @@ LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
 
 error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:119:9
    |
 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         ^^^^^^^^^---------^^^^^^^^^^^^
@@ -451,7 +415,7 @@ LL |     *b = U;
    |     ------ mutable borrow later used here
 
 error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:125:9
    |
 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         ^^^^^^^^^---------^^^^^^^^^^^^
@@ -463,7 +427,7 @@ LL |     *b = U;
    |     ------ mutable borrow later used here
 
 error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
-  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:135:9
+  --> $DIR/borrowck-pat-ref-mut-and-ref.rs:131:9
    |
 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
    |         ^^^^^^^^^---------^^^^^^^^^^^^
@@ -484,7 +448,7 @@ LL |     fn f4_also_moved(ref a @ ref mut b @ c: U) {}
    |                      |       value borrowed here after move
    |                      move occurs because value has type `U`, which does not implement the `Copy` trait
 
-error: aborting due to 51 previous errors
+error: aborting due to 47 previous errors
 
 Some errors have detailed explanations: E0382, E0502, E0507, E0594.
 For more information about an error, try `rustc --explain E0382`.
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs
index c58f0413499..339814e1e31 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs
@@ -84,8 +84,6 @@ fn main() {
         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
             //~^ ERROR cannot borrow value as mutable more than once at a time
             //~| ERROR cannot borrow value as mutable more than once at a time
-            //~| ERROR cannot borrow value as mutable more than once at a time
-            //~| ERROR cannot borrow value as mutable more than once at a time
             *b = U;
         }
     }
@@ -93,6 +91,8 @@ fn main() {
         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
             //~^ ERROR cannot borrow value as mutable more than once at a time
             //~| ERROR cannot borrow value as mutable more than once at a time
+            //~| ERROR cannot borrow value as mutable more than once at a time
+            //~| ERROR cannot borrow value as mutable more than once at a time
             *a = Err(U);
 
             // FIXME: The binding name value used above makes for problematic diagnostics.
@@ -103,6 +103,8 @@ fn main() {
         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
             //~^ ERROR cannot borrow value as mutable more than once at a time
             //~| ERROR cannot borrow value as mutable more than once at a time
+            //~| ERROR cannot borrow value as mutable more than once at a time
+            //~| ERROR cannot borrow value as mutable more than once at a time
             drop(a);
         }
     }
diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr
index 5ae71c2a9fd..0370037f242 100644
--- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr
+++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr
@@ -168,7 +168,7 @@ LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
    |                                     first mutable borrow, by `a`, occurs here
 
 error: cannot borrow value as mutable more than once at a time
-  --> $DIR/borrowck-pat-ref-mut-twice.rs:93:9
+  --> $DIR/borrowck-pat-ref-mut-twice.rs:91:9
    |
 LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
    |         ---------^^^^^^---------^
@@ -177,7 +177,7 @@ LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
    |         first mutable borrow, by `a`, occurs here
 
 error: cannot borrow value as mutable more than once at a time
-  --> $DIR/borrowck-pat-ref-mut-twice.rs:93:37
+  --> $DIR/borrowck-pat-ref-mut-twice.rs:91:37
    |
 LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
    |                                     ---------^^^^^^^---------^
@@ -283,28 +283,52 @@ LL |     *b = U;
    |     ------ first borrow later used here
 
 error[E0499]: cannot borrow value as mutable more than once at a time
-  --> $DIR/borrowck-pat-ref-mut-twice.rs:84:9
+  --> $DIR/borrowck-pat-ref-mut-twice.rs:91:24
    |
 LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
-   |         ^^^^^^^^^^^^^^^---------^
+   |         ---------------^^^^^^^^^-
    |         |              |
-   |         |              first mutable borrow occurs here
-   |         second mutable borrow occurs here
+   |         |              second mutable borrow occurs here
+   |         first mutable borrow occurs here
 ...
-LL |             *b = U;
-   |             ------ first borrow later used here
+LL |             *a = Err(U);
+   |             ----------- first borrow later used here
 
 error[E0499]: cannot borrow value as mutable more than once at a time
-  --> $DIR/borrowck-pat-ref-mut-twice.rs:84:37
+  --> $DIR/borrowck-pat-ref-mut-twice.rs:91:53
+   |
+LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
+   |                                     ----------------^^^^^^^^^-
+   |                                     |               |
+   |                                     |               second mutable borrow occurs here
+   |                                     first mutable borrow occurs here
+...
+LL |             *a = Err(U);
+   |             ----------- first borrow later used here
+
+error[E0499]: cannot borrow value as mutable more than once at a time
+  --> $DIR/borrowck-pat-ref-mut-twice.rs:103:24
+   |
+LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
+   |         ---------------^^^^^^^^^-
+   |         |              |
+   |         |              second mutable borrow occurs here
+   |         first mutable borrow occurs here
+...
+LL |             drop(a);
+   |                  - first borrow later used here
+
+error[E0499]: cannot borrow value as mutable more than once at a time
+  --> $DIR/borrowck-pat-ref-mut-twice.rs:103:53
    |
 LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
-   |                                     ^^^^^^^^^^^^^^^^---------^
+   |                                     ----------------^^^^^^^^^-
    |                                     |               |
-   |                                     |               first mutable borrow occurs here
-   |                                     second mutable borrow occurs here
+   |                                     |               second mutable borrow occurs here
+   |                                     first mutable borrow occurs here
 ...
-LL |             *b = U;
-   |             ------ first borrow later used here
+LL |             drop(a);
+   |                  - first borrow later used here
 
 error[E0382]: borrow of moved value
   --> $DIR/borrowck-pat-ref-mut-twice.rs:23:34
@@ -316,7 +340,7 @@ LL |     fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
    |                      |           value borrowed here after move
    |                      move occurs because value has type `U`, which does not implement the `Copy` trait
 
-error: aborting due to 29 previous errors
+error: aborting due to 31 previous errors
 
 Some errors have detailed explanations: E0382, E0499.
 For more information about an error, try `rustc --explain E0382`.