don't use drop_in_place as an intrinsic

pull/10/head
Alexis Beingessner 9 years ago committed by Manish Goregaokar
parent 150a6b4a85
commit 799b247059

@ -26,12 +26,11 @@ this is totally fine.
For instance, a custom implementation of `Box` might write `Drop` like this:
```rust
#![feature(alloc, heap_api, core_intrinsics, unique)]
#![feature(alloc, heap_api, drop_in_place, unique)]
extern crate alloc;
use std::ptr::Unique;
use std::intrinsics::drop_in_place;
use std::ptr::{drop_in_place, Unique};
use std::mem;
use alloc::heap;
@ -58,12 +57,11 @@ use-after-free the `ptr` because when drop exits, it becomes inaccessible.
However this wouldn't work:
```rust
#![feature(alloc, heap_api, core_intrinsics, unique)]
#![feature(alloc, heap_api, drop_in_place, unique)]
extern crate alloc;
use std::ptr::Unique;
use std::intrinsics::drop_in_place;
use std::ptr::{drop_in_place, Unique};
use std::mem;
use alloc::heap;
@ -137,12 +135,11 @@ The classic safe solution to overriding recursive drop and allowing moving out
of Self during `drop` is to use an Option:
```rust
#![feature(alloc, heap_api, core_intrinsics, unique)]
#![feature(alloc, heap_api, drop_in_place, unique)]
extern crate alloc;
use std::ptr::Unique;
use std::intrinsics::drop_in_place;
use std::ptr::{drop_in_place, Unique};
use std::mem;
use alloc::heap;

Loading…
Cancel
Save