]> git.lizzy.rs Git - rust.git/commitdiff
Fix is_dangling import when Arc is #[cfg]’ed out
authorSimon Sapin <simon.sapin@exyr.org>
Fri, 6 Jul 2018 23:44:57 +0000 (01:44 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Fri, 6 Jul 2018 23:44:57 +0000 (01:44 +0200)
src/liballoc/rc.rs
src/liballoc/sync.rs

index 3f32abe1ea9599316215aecf1317e115ed16bb7f..5b71d0b85a03eb06d2d846094821e3461a1b0a16 100644 (file)
 
 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 @@ pub fn new() -> 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.
index ea8616bf1d05c8d24d3846899d53b591a01d2a63..6710878b31d945bdc2cfdf7a4cd111ec544bd672 100644 (file)
@@ -34,6 +34,7 @@
 
 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 @@ pub fn new() -> 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.