From 3902190ac4d64962b2c1ac9a6ae88777b7112f82 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 10 Feb 2015 10:04:39 +0100 Subject: Switch drop-flag to `u8` to allow special tags to instrument state. Refactored code so that the drop-flag values for initialized (`DTOR_NEEDED`) versus dropped (`DTOR_DONE`) are given explicit names. Add `mem::dropped()` (which with `DTOR_DONE == 0` is semantically the same as `mem::zeroed`, but the point is that it abstracts away from the particular choice of value for `DTOR_DONE`). Filling-drop needs to use something other than `ptr::read_and_zero`, so I added such a function: `ptr::read_and_drop`. But, libraries should not use it if they can otherwise avoid it. Fixes to tests to accommodate filling-drop. --- src/libsyntax/fold.rs | 2 +- src/libsyntax/ptr.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 105a61d0857..d4451cc7b71 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -40,7 +40,7 @@ impl MoveMap for Vec { for p in &mut self { unsafe { // FIXME(#5016) this shouldn't need to zero to be safe. - ptr::write(p, f(ptr::read_and_zero(p))); + ptr::write(p, f(ptr::read_and_drop(p))); } } self diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index ca3a1848c3a..7e0bcd3e1dc 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -71,8 +71,8 @@ impl P { { unsafe { let p = &mut *self.ptr; - // FIXME(#5016) this shouldn't need to zero to be safe. - ptr::write(p, f(ptr::read_and_zero(p))); + // FIXME(#5016) this shouldn't need to drop-fill to be safe. + ptr::write(p, f(ptr::read_and_drop(p))); } self } -- cgit 1.4.1-3-g733a5