From 799b24705927704e4e24c5a51880e02fe7220e41 Mon Sep 17 00:00:00 2001 From: Alexis Beingessner Date: Wed, 19 Aug 2015 15:55:36 -0700 Subject: [PATCH] don't use drop_in_place as an intrinsic --- destructors.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/destructors.md b/destructors.md index 604370b..c6fa5b0 100644 --- a/destructors.md +++ b/destructors.md @@ -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;