Skip to content

Commit 67202b8

Browse files
committed
Fix is_dangling import when Arc is #[cfg]’ed out
1 parent 5717d99 commit 67202b8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/liballoc/rc.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ use core::convert::From;
261261

262262
use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
263263
use string::String;
264-
use sync::is_dangling;
265264
use vec::Vec;
266265

267266
struct RcBox<T: ?Sized> {
@@ -1192,6 +1191,12 @@ impl<T> Weak<T> {
11921191
}
11931192
}
11941193

1194+
pub(crate) fn is_dangling<T: ?Sized>(ptr: NonNull<T>) -> bool {
1195+
let address = ptr.as_ptr() as *mut () as usize;
1196+
let align = align_of_val(unsafe { ptr.as_ref() });
1197+
address == align
1198+
}
1199+
11951200
impl<T: ?Sized> Weak<T> {
11961201
/// Attempts to upgrade the `Weak` pointer to an [`Rc`], extending
11971202
/// the lifetime of the value if successful.

src/liballoc/sync.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use core::convert::From;
3434

3535
use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error};
3636
use boxed::Box;
37+
use rc::is_dangling;
3738
use string::String;
3839
use vec::Vec;
3940

@@ -1038,12 +1039,6 @@ impl<T> Weak<T> {
10381039
}
10391040
}
10401041

1041-
pub(crate) fn is_dangling<T: ?Sized>(ptr: NonNull<T>) -> bool {
1042-
let address = ptr.as_ptr() as *mut () as usize;
1043-
let align = align_of_val(unsafe { ptr.as_ref() });
1044-
address == align
1045-
}
1046-
10471042
impl<T: ?Sized> Weak<T> {
10481043
/// Attempts to upgrade the `Weak` pointer to an [`Arc`], extending
10491044
/// the lifetime of the value if successful.

0 commit comments

Comments
 (0)