about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2025-02-14 18:35:43 -0300
committerSantiago Pastorino <spastorino@gmail.com>2025-03-06 17:58:33 -0300
commit6eb6ff62f78560720f6902421dcd482cb70482ed (patch)
tree6923e9a37218d1e87fa0c7c178be15bd5273f74a /compiler/rustc_borrowck/src
parent292aa8704957f0c0a94cc0cb01c74267d2bdfe27 (diff)
downloadrust-6eb6ff62f78560720f6902421dcd482cb70482ed.tar.gz
rust-6eb6ff62f78560720f6902421dcd482cb70482ed.zip
Allow to mutate use captures
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/lib.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index 68e0ab0933e..64a533e05ff 100644
--- a/compiler/rustc_borrowck/src/lib.rs
+++ b/compiler/rustc_borrowck/src/lib.rs
@@ -1490,14 +1490,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
                         let stmt = &bbd.statements[loc.statement_index];
                         debug!("temporary assigned in: stmt={:?}", stmt);
 
-                        if let StatementKind::Assign(box (_, Rvalue::Ref(_, _, source))) = stmt.kind
-                        {
-                            propagate_closure_used_mut_place(self, source);
-                        } else {
-                            bug!(
-                                "closures should only capture user variables \
+                        match stmt.kind {
+                            StatementKind::Assign(box (
+                                _,
+                                Rvalue::Ref(_, _, source)
+                                | Rvalue::Use(Operand::Copy(source) | Operand::Move(source)),
+                            )) => {
+                                propagate_closure_used_mut_place(self, source);
+                            }
+                            _ => {
+                                bug!(
+                                    "closures should only capture user variables \
                                  or references to user variables"
-                            );
+                                );
+                            }
                         }
                     }
                     _ => propagate_closure_used_mut_place(self, place),