diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2018-07-07 01:44:57 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-07-07 01:44:57 +0200 |
| commit | 67202b8b68d93c90e89ca001945865f13bc97154 (patch) | |
| tree | a8794d3b4071cd0b9013df73f05d0195f7af7640 /src/liballoc | |
| parent | 5717d99d1b3b76ec7814c95dfcc0399ab4ddaa83 (diff) | |
| download | rust-67202b8b68d93c90e89ca001945865f13bc97154.tar.gz rust-67202b8b68d93c90e89ca001945865f13bc97154.zip | |
Fix is_dangling import when Arc is #[cfg]’ed out
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/rc.rs | 7 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 7 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 3f32abe1ea9..5b71d0b85a0 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -261,7 +261,6 @@ use core::convert::From; use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}; use string::String; -use sync::is_dangling; use vec::Vec; 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> { /// Attempts to upgrade the `Weak` pointer to an [`Rc`], extending /// the lifetime of the value if successful. diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index ea8616bf1d0..6710878b31d 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -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. |
