Skip to content

Commit b8a250f

Browse files
committed
update comment on MutBorrowKind::ClosureCapture
1 parent a52cc0a commit b8a250f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

compiler/rustc_middle/src/mir/syntax.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub enum BorrowKind {
190190
#[derive(Hash, HashStable)]
191191
pub enum MutBorrowKind {
192192
Default,
193-
/// this borrow arose from method-call auto-ref. (i.e., `adjustment::Adjust::Borrow`)
193+
/// This borrow arose from method-call auto-ref. (i.e., `adjustment::Adjust::Borrow`)
194194
TwoPhaseBorrow,
195195
/// Data must be immutable but not aliasable. This kind of borrow
196196
/// cannot currently be expressed by the user and is used only in
@@ -226,9 +226,12 @@ pub enum MutBorrowKind {
226226
/// user code, if awkward, but extra weird for closures, since the
227227
/// borrow is hidden.
228228
///
229-
/// So we introduce a "unique imm" borrow -- the referent is
230-
/// immutable, but not aliasable. This solves the problem. For
231-
/// simplicity, we don't give users the way to express this
229+
/// So we introduce a `ClosureCapture` borrow -- user will not have to mark the variable
230+
/// containing the mutable reference as `mut`, as they didn't ever
231+
/// intend to mutate the mutable reference itself. We still mutable capture it in order to
232+
/// mutate the pointed value through it (but not mutating the reference itself).
233+
///
234+
/// This solves the problem. For simplicity, we don't give users the way to express this
232235
/// borrow, it's just used when translating closures.
233236
ClosureCapture,
234237
}

0 commit comments

Comments
 (0)