Skip to content

Commit

Permalink
Update description to reflect language changes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zzmp committed Jun 11, 2014
1 parent b1302f9 commit 4f90025
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/doc/guide-lifetimes.md
Expand Up @@ -275,8 +275,10 @@ invalidate the pointer `owner_age`.

# Borrowing and enums

The previous example showed that the type system forbids any borrowing
of owned boxes found in aliasable, mutable memory. This restriction
The previous example showed that the type system forbids any 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 restriction
prevents pointers from pointing into freed memory. There is one other
case where the compiler must be very careful to ensure that pointers
remain valid: pointers into the interior of an `enum`.
Expand Down

5 comments on commit 4f90025

@bors
Copy link
Contributor

@bors bors commented on 4f90025 Jun 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at zzmp@4f90025

@bors
Copy link
Contributor

@bors bors commented on 4f90025 Jun 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging zzmp/rust/patch-2 = 4f90025 into auto

@bors
Copy link
Contributor

@bors bors commented on 4f90025 Jun 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zzmp/rust/patch-2 = 4f90025 merged ok, testing candidate = 8b87c3a

@bors
Copy link
Contributor

@bors bors commented on 4f90025 Jun 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 8b87c3a

Please sign in to comment.