diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-08-23 10:39:30 +0300 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-08-24 13:23:37 +0300 |
| commit | 119508cdb4051280a6b89d4ba1a8157f1113d379 (patch) | |
| tree | eaa0cb8e2df53fad235592948a07f400b2b93a87 /src/liballoc/rc.rs | |
| parent | d0654ae5e53124273340624aa2e25f5a9aa9ecb3 (diff) | |
| download | rust-119508cdb4051280a6b89d4ba1a8157f1113d379.tar.gz rust-119508cdb4051280a6b89d4ba1a8157f1113d379.zip | |
Remove drop flags from structs and enums implementing Drop.
Diffstat (limited to 'src/liballoc/rc.rs')
| -rw-r--r-- | src/liballoc/rc.rs | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 3a158240c3a..8e43e9eec16 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -182,7 +182,7 @@ struct RcBox<T: ?Sized> { /// A reference-counted pointer type over an immutable value. /// /// See the [module level documentation](./index.html) for more details. -#[unsafe_no_drop_flag] +#[cfg_attr(stage0, unsafe_no_drop_flag)] #[stable(feature = "rust1", since = "1.0.0")] pub struct Rc<T: ?Sized> { ptr: Shared<RcBox<T>>, @@ -466,21 +466,18 @@ impl<T: ?Sized> Drop for Rc<T> { fn drop(&mut self) { unsafe { let ptr = *self.ptr; - let thin = ptr as *const (); - if thin as usize != mem::POST_DROP_USIZE { - self.dec_strong(); - if self.strong() == 0 { - // destroy the contained object - ptr::drop_in_place(&mut (*ptr).value); + self.dec_strong(); + if self.strong() == 0 { + // destroy the contained object + ptr::drop_in_place(&mut (*ptr).value); - // remove the implicit "strong weak" pointer now that we've - // destroyed the contents. - self.dec_weak(); + // remove the implicit "strong weak" pointer now that we've + // destroyed the contents. + self.dec_weak(); - if self.weak() == 0 { - deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) - } + if self.weak() == 0 { + deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) } } } @@ -724,7 +721,7 @@ impl<T> From<T> for Rc<T> { /// dropped. /// /// See the [module level documentation](./index.html) for more. -#[unsafe_no_drop_flag] +#[cfg_attr(stage0, unsafe_no_drop_flag)] #[stable(feature = "rc_weak", since = "1.4.0")] pub struct Weak<T: ?Sized> { ptr: Shared<RcBox<T>>, @@ -825,15 +822,12 @@ impl<T: ?Sized> Drop for Weak<T> { fn drop(&mut self) { unsafe { let ptr = *self.ptr; - let thin = ptr as *const (); - if thin as usize != mem::POST_DROP_USIZE { - self.dec_weak(); - // the weak count starts at 1, and will only go to zero if all - // the strong pointers have disappeared. - if self.weak() == 0 { - deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) - } + self.dec_weak(); + // the weak count starts at 1, and will only go to zero if all + // the strong pointers have disappeared. + if self.weak() == 0 { + deallocate(ptr as *mut u8, size_of_val(&*ptr), align_of_val(&*ptr)) } } } |
