Introduce and avoid dropck (#353)

pull/364/head
Arthur Milchior 2 years ago committed by GitHub
parent 45a76e867a
commit 784685cc48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -121,9 +121,9 @@ Interestingly, only generic types need to worry about this. If they aren't
generic, then the only lifetimes they can harbor are `'static`, which will truly generic, then the only lifetimes they can harbor are `'static`, which will truly
live _forever_. This is why this problem is referred to as _sound generic drop_. live _forever_. This is why this problem is referred to as _sound generic drop_.
Sound generic drop is enforced by the _drop checker_. As of this writing, some Sound generic drop is enforced by the _drop checker_. As of this writing, some
of the finer details of how the drop checker validates types is totally up in of the finer details of how the drop checker (also called dropck) validates
the air. However The Big Rule is the subtlety that we have focused on this whole types is totally up in the air. However The Big Rule is the subtlety that we
section: have focused on this whole section:
**For a generic type to soundly implement drop, its generics arguments must **For a generic type to soundly implement drop, its generics arguments must
strictly outlive it.** strictly outlive it.**

@ -64,9 +64,9 @@ about Vec dropping any T's in its destructor for determining drop check
soundness. This will in turn allow people to create unsoundness using soundness. This will in turn allow people to create unsoundness using
Vec's destructor. Vec's destructor.
In order to tell dropck that we *do* own values of type T, and therefore may In order to tell the drop checker that we *do* own values of type T, and
drop some T's when *we* drop, we must add an extra `PhantomData` saying exactly therefore may drop some T's when *we* drop, we must add an extra `PhantomData`
that: saying exactly that:
```rust ```rust
use std::marker; use std::marker;

Loading…
Cancel
Save