Skip to content

Commit 4f90025

Browse files
committed
Update description to reflect language changes
Previously, the type system's restrictions on borrowing were summarized as > The previous example showed that the type system forbids any borrowing of owned boxes found in aliasable, mutable memory This did not jive with the example, which allowed mutations so long as the borrowed reference had been returned. Also, the language has changed to no longer allow aliasable mutable locations. This changes the summary to read > The previous example showed that the type system forbids mutations of owned boxed values while they are being borrowed. In general, the type system also forbids borrowing a value as mutable if it is already being borrowed - either as a mutable reference or an immutable one. This adds more general information for the experienced reader as well, to offer a more complete understanding.
1 parent b1302f9 commit 4f90025

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/doc/guide-lifetimes.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,10 @@ invalidate the pointer `owner_age`.
275275

276276
# Borrowing and enums
277277

278-
The previous example showed that the type system forbids any borrowing
279-
of owned boxes found in aliasable, mutable memory. This restriction
278+
The previous example showed that the type system forbids any mutations
279+
of owned boxed values while they are being borrowed. In general, the type
280+
system also forbids borrowing a value as mutable if it is already being
281+
borrowed - either as a mutable reference or an immutable one. This restriction
280282
prevents pointers from pointing into freed memory. There is one other
281283
case where the compiler must be very careful to ensure that pointers
282284
remain valid: pointers into the interior of an `enum`.

0 commit comments

Comments
 (0)