mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
rc: Take *const T in is_dangling
It is not important which one is used since `is_dangling` does not access memory, but `*const` removes the needs of `*const T` -> `*mut T` casts in `from_raw_in`.
This commit is contained in:
parent
8d76d07666
commit
2c23c06c32
@ -2778,7 +2778,7 @@ impl<T, A: Allocator> Weak<T, A> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_dangling<T: ?Sized>(ptr: *mut T) -> bool {
|
||||
pub(crate) fn is_dangling<T: ?Sized>(ptr: *const T) -> bool {
|
||||
(ptr.cast::<()>()).addr() == usize::MAX
|
||||
}
|
||||
|
||||
@ -3003,7 +3003,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
|
||||
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self {
|
||||
// See Weak::as_ptr for context on how the input pointer is derived.
|
||||
|
||||
let ptr = if is_dangling(ptr as *mut T) {
|
||||
let ptr = if is_dangling(ptr) {
|
||||
// This is a dangling Weak.
|
||||
ptr as *mut RcBox<T>
|
||||
} else {
|
||||
|
@ -2722,7 +2722,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
|
||||
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self {
|
||||
// See Weak::as_ptr for context on how the input pointer is derived.
|
||||
|
||||
let ptr = if is_dangling(ptr as *mut T) {
|
||||
let ptr = if is_dangling(ptr) {
|
||||
// This is a dangling Weak.
|
||||
ptr as *mut ArcInner<T>
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user