]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_typeck/src/expr_use_visitor.rs
Rollup merge of #87645 - LeSeulArtichaut:issue-87414, r=oli-obk
[rust.git] / compiler / rustc_typeck / src / expr_use_visitor.rs
index 806f1a2711c012b9d52d7830d5d40efd755a5b7a..1d7852d964c1dd428108c9934c0ffbe40e0886ce 100644 (file)
@@ -267,12 +267,21 @@ pub fn walk_expr(&mut self, expr: &hir::Expr<'_>) {
                                     }
                                 }
                             }
-                            PatKind::Lit(_) => {
-                                // If the PatKind is a Lit then we want
+                            PatKind::Lit(_) | PatKind::Range(..) => {
+                                // If the PatKind is a Lit or a Range then we want
                                 // to borrow discr.
                                 needs_to_be_read = true;
                             }
-                            _ => {}
+                            PatKind::Or(_)
+                            | PatKind::Box(_)
+                            | PatKind::Slice(..)
+                            | PatKind::Ref(..)
+                            | PatKind::Wild => {
+                                // If the PatKind is Or, Box, Slice or Ref, the decision is made later
+                                // as these patterns contains subpatterns
+                                // If the PatKind is Wild, the decision is made based on the other patterns being
+                                // examined
+                            }
                         }
                     }));
                 }
@@ -667,7 +676,7 @@ fn walk_pat(&mut self, discr_place: &PlaceWithHirId<'tcx>, pat: &hir::Pat<'_>) {
     /// When the current body being handled is a closure, then we must make sure that
     /// - The parent closure only captures Places from the nested closure that are not local to it.
     ///
-    /// In the following example the closures `c` only captures `p.x`` even though `incr`
+    /// In the following example the closures `c` only captures `p.x` even though `incr`
     /// is a capture of the nested closure
     ///
     /// ```rust,ignore(cannot-test-this-because-pseudo-code)