1
Fork 0

Fix is_dangling import when Arc is #[cfg]’ed out

This commit is contained in:
Simon Sapin 2018-07-07 01:44:57 +02:00
parent 5717d99d1b
commit 67202b8b68
2 changed files with 7 additions and 7 deletions

View file

@ -34,6 +34,7 @@ use core::convert::From;
use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
use boxed::Box;
use rc::is_dangling;
use string::String;
use vec::Vec;
@ -1038,12 +1039,6 @@ impl<T> Weak<T> {
}
}
pub(crate) fn is_dangling<T: ?Sized>(ptr: NonNull<T>) -> bool {
let address = ptr.as_ptr() as *mut () as usize;
let align = align_of_val(unsafe { ptr.as_ref() });
address == align
}
impl<T: ?Sized> Weak<T> {
/// Attempts to upgrade the `Weak` pointer to an [`Arc`], extending
/// the lifetime of the value if successful.