diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-02-10 10:04:39 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-03-26 14:08:54 +0100 |
| commit | 3902190ac4d64962b2c1ac9a6ae88777b7112f82 (patch) | |
| tree | 61759f62fbca6a1e9c25e3e95dd1d957340510df /src/libsyntax | |
| parent | 1501f33e76f6f9621aa08fb0cbbc5f85a5ac7f0f (diff) | |
| download | rust-3902190ac4d64962b2c1ac9a6ae88777b7112f82.tar.gz rust-3902190ac4d64962b2c1ac9a6ae88777b7112f82.zip | |
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.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ptr.rs | 4 |
2 files changed, 3 insertions, 3 deletions
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<T> MoveMap<T> for Vec<T> { 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<T: 'static> P<T> { { 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 } |
