about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorZiru Niu <zirconium.n@gmail.com>2023-06-07 15:44:32 +0800
committerZiru Niu <zirconium.n@gmail.com>2023-06-20 20:55:31 +0800
commitb8a250fc4f053636c481b7543cfaa1fab2df48ad (patch)
treea3520ad3d49950d99f2420ea5cbfeab8a369a8fb /compiler
parenta52cc0a8c967253e0f61c7f77c820ab6e1f2e73e (diff)
downloadrust-b8a250fc4f053636c481b7543cfaa1fab2df48ad.tar.gz
rust-b8a250fc4f053636c481b7543cfaa1fab2df48ad.zip
update comment on `MutBorrowKind::ClosureCapture`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/mir/syntax.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs
index 458672676e2..abb3b3d953b 100644
--- a/compiler/rustc_middle/src/mir/syntax.rs
+++ b/compiler/rustc_middle/src/mir/syntax.rs
@@ -190,7 +190,7 @@ pub enum BorrowKind {
 #[derive(Hash, HashStable)]
 pub enum MutBorrowKind {
     Default,
-    /// this borrow arose from method-call auto-ref. (i.e., `adjustment::Adjust::Borrow`)
+    /// This borrow arose from method-call auto-ref. (i.e., `adjustment::Adjust::Borrow`)
     TwoPhaseBorrow,
     /// Data must be immutable but not aliasable. This kind of borrow
     /// cannot currently be expressed by the user and is used only in
@@ -226,9 +226,12 @@ pub enum MutBorrowKind {
     /// user code, if awkward, but extra weird for closures, since the
     /// borrow is hidden.
     ///
-    /// So we introduce a "unique imm" borrow -- the referent is
-    /// immutable, but not aliasable. This solves the problem. For
-    /// simplicity, we don't give users the way to express this
+    /// So we introduce a `ClosureCapture` borrow -- user will not have to mark the variable
+    /// containing the mutable reference as `mut`, as they didn't ever
+    /// intend to mutate the mutable reference itself. We still mutable capture it in order to
+    /// mutate the pointed value through it (but not mutating the reference itself).
+    ///
+    /// This solves the problem. For simplicity, we don't give users the way to express this
     /// borrow, it's just used when translating closures.
     ClosureCapture,
 }