diff options
| author | bors <bors@rust-lang.org> | 2015-12-31 11:42:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-12-31 11:42:16 +0000 |
| commit | 8aee5826f9b0ce3e6bcd4c5a292fdc22ac8c78fc (patch) | |
| tree | 609e67a202255a6aebe7eec5304eb31dada73fe7 /src/liballoc/rc.rs | |
| parent | 7f3201d13108f411cf574a77b732f422245e3fe0 (diff) | |
| parent | 2cff12e0d6d846c1c2a4c4449ecf7473658573ef (diff) | |
| download | rust-8aee5826f9b0ce3e6bcd4c5a292fdc22ac8c78fc.tar.gz rust-8aee5826f9b0ce3e6bcd4c5a292fdc22ac8c78fc.zip | |
Auto merge of #30593 - steveklabnik:small_rc_refactoring, r=Gankro
This hairy conditional doesn't need to be so. It _does_ need to be a thin pointer, otherwise, it will fail to compile, so let's pull that out into a temporary for future readers of the source. /cc @nrc @SimonSapin @Gankro @durka , who brought this up on IRC
Diffstat (limited to 'src/liballoc/rc.rs')
| -rw-r--r-- | src/liballoc/rc.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index ba61a37456a..2c45e88bb24 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -449,8 +449,9 @@ impl<T: ?Sized> Drop for Rc<T> { fn drop(&mut self) { unsafe { let ptr = *self._ptr; - if !(*(&ptr as *const _ as *const *const ())).is_null() && - ptr as *const () as usize != mem::POST_DROP_USIZE { + let thin = ptr as *const (); + + if thin as usize != mem::POST_DROP_USIZE { self.dec_strong(); if self.strong() == 0 { // destroy the contained object @@ -782,8 +783,9 @@ impl<T: ?Sized> Drop for Weak<T> { fn drop(&mut self) { unsafe { let ptr = *self._ptr; - if !(*(&ptr as *const _ as *const *const ())).is_null() && - ptr as *const () as usize != mem::POST_DROP_USIZE { + 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. |
