Fix is_dangling import when Arc is #[cfg]’ed out
This commit is contained in:
parent
5717d99d1b
commit
67202b8b68
2 changed files with 7 additions and 7 deletions
|
@ -261,7 +261,6 @@ use core::convert::From;
|
||||||
|
|
||||||
use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
|
use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
|
||||||
use string::String;
|
use string::String;
|
||||||
use sync::is_dangling;
|
|
||||||
use vec::Vec;
|
use vec::Vec;
|
||||||
|
|
||||||
struct RcBox<T: ?Sized> {
|
struct RcBox<T: ?Sized> {
|
||||||
|
@ -1192,6 +1191,12 @@ 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> {
|
impl<T: ?Sized> Weak<T> {
|
||||||
/// Attempts to upgrade the `Weak` pointer to an [`Rc`], extending
|
/// Attempts to upgrade the `Weak` pointer to an [`Rc`], extending
|
||||||
/// the lifetime of the value if successful.
|
/// the lifetime of the value if successful.
|
||||||
|
|
|
@ -34,6 +34,7 @@ use core::convert::From;
|
||||||
|
|
||||||
use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
|
use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
|
||||||
use boxed::Box;
|
use boxed::Box;
|
||||||
|
use rc::is_dangling;
|
||||||
use string::String;
|
use string::String;
|
||||||
use vec::Vec;
|
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> {
|
impl<T: ?Sized> Weak<T> {
|
||||||
/// Attempts to upgrade the `Weak` pointer to an [`Arc`], extending
|
/// Attempts to upgrade the `Weak` pointer to an [`Arc`], extending
|
||||||
/// the lifetime of the value if successful.
|
/// the lifetime of the value if successful.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue