Skip to content

Commit 0c1fc1c

Browse files
author
Keegan McAllister
committed
borrowck/README.md: Clarify MUTABILITY and ALIASABLE
1 parent bb22c10 commit 0c1fc1c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/librustc_borrowck/borrowck/README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,11 @@ that will go into the final loan. We'll discuss in more detail below.
261261
## Checking mutability
262262

263263
Checking mutability is fairly straightforward. We just want to prevent
264-
immutable data from being borrowed as mutable. Note that it is ok to
265-
borrow mutable data as immutable, since that is simply a
266-
freeze. Formally we define a predicate `MUTABLE(LV, MQ)` which, if
267-
defined, means that "borrowing `LV` with mutability `MQ` is ok. The
268-
Rust code corresponding to this predicate is the function
269-
`check_mutability` in `middle::borrowck::gather_loans`.
264+
immutable data from being borrowed as mutable. Note that it is ok to borrow
265+
mutable data as immutable, since that is simply a freeze. The judgement
266+
`MUTABILITY(LV, MQ)` means the mutability of `LV` is compatible with a borrow
267+
of mutability `MQ`. The Rust code corresponding to this predicate is the
268+
function `check_mutability` in `middle::borrowck::gather_loans`.
270269

271270
### Checking mutability of variables
272271

@@ -321,12 +320,11 @@ MUTABILITY(*LV, MQ) // M-Deref-Borrowed-Mut
321320

322321
## Checking aliasability
323322

324-
The goal of the aliasability check is to ensure that we never permit
325-
`&mut` borrows of aliasable data. Formally we define a predicate
326-
`ALIASABLE(LV, MQ)` which if defined means that
327-
"borrowing `LV` with mutability `MQ` is ok". The
328-
Rust code corresponding to this predicate is the function
329-
`check_aliasability()` in `middle::borrowck::gather_loans`.
323+
The goal of the aliasability check is to ensure that we never permit `&mut`
324+
borrows of aliasable data. The judgement `ALIASABLE(LV, MQ)` means the
325+
aliasability of `LV` is compatible with a borrow of mutability `MQ`. The Rust
326+
code corresponding to this predicate is the function `check_aliasability()` in
327+
`middle::borrowck::gather_loans`.
330328

331329
### Checking aliasability of variables
332330

0 commit comments

Comments
 (0)