about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_mir_build/src/build/matches/simplify.rs20
-rw-r--r--src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs3
-rw-r--r--src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr2
3 files changed, 14 insertions, 11 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs
index e5fee5df06a..29fc23c324f 100644
--- a/compiler/rustc_mir_build/src/build/matches/simplify.rs
+++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs
@@ -44,10 +44,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         candidate: &mut Candidate<'pat, 'tcx>,
     ) -> bool {
         // repeatedly simplify match pairs until fixed point is reached
-        debug!("simplify_candidate(candidate={:?})", candidate);
+        debug!(?candidate, "simplify_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
+        // existing_bindings and new_bindings exists to keep the semantics in order.
+        // Reversing the binding order for bindings after `@` changes the 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:
@@ -64,7 +64,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         // 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 existing_bindings = mem::take(&mut candidate.bindings);
         let mut new_bindings = Vec::new();
         loop {
             let match_pairs = mem::take(&mut candidate.match_pairs);
@@ -72,8 +72,8 @@ 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);
+                existing_bindings.extend_from_slice(&new_bindings);
+                mem::swap(&mut candidate.bindings, &mut existing_bindings);
                 candidate.subcandidates = self.create_or_subcandidates(candidate, place, pats);
                 return true;
             }
@@ -89,7 +89,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     }
                 }
             }
-            // issue #69971: the binding order should be right to left if there are more
+            // Avoid issue #69971: the binding order should be right to left if there are more
             // bindings after `@` to please the borrow checker
             // Ex
             // struct NonCopyStruct {
@@ -107,15 +107,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
             candidate.bindings.clear();
 
             if !changed {
-                exisiting_bindings.extend_from_slice(&new_bindings);
-                mem::swap(&mut candidate.bindings, &mut exisiting_bindings);
+                existing_bindings.extend_from_slice(&new_bindings);
+                mem::swap(&mut candidate.bindings, &mut existing_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.
                 candidate
                     .match_pairs
                     .sort_by_key(|pair| matches!(*pair.pattern.kind, PatKind::Or { .. }));
-                debug!("simplify_candidate: simplifed {:?}", candidate);
+                debug!(simplified = ?candidate, "simplify_candidate");
                 return false; // if we were not able to simplify any, done.
             }
         }
diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs
index 1dc9716f54b..f731aa2e963 100644
--- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs
+++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.rs
@@ -8,6 +8,9 @@ struct C;
 struct NC<A, B>(A, B);
 
 fn main() {
+    // this compiles
+    let a @ NC(b, c) = NC(C, C);
+
     let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C));
     //~^ ERROR use of partially moved value
 }
diff --git a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr
index 9ffbadf36a6..183a37176ec 100644
--- a/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr
+++ b/src/test/ui/pattern/bindings-after-at/copy-and-move-mixed.stderr
@@ -1,5 +1,5 @@
 error[E0382]: use of partially moved value
-  --> $DIR/copy-and-move-mixed.rs:11:9
+  --> $DIR/copy-and-move-mixed.rs:14:9
    |
 LL |     let a @ NC(b, c @ NC(d, e)) = NC(C, NC(C, C));
    |         ^^^^^^^^^^------------^