Skip to content

Commit 00f88b3

Browse files
authored
Unrolled build for rust-lang#119434
Rollup merge of rust-lang#119434 - taiki-e:rc-is-dangling, r=Mark-Simulacrum 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`.
2 parents 1a47f5b + 2c23c06 commit 00f88b3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/alloc/src/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,7 @@ impl<T, A: Allocator> Weak<T, A> {
27782778
}
27792779
}
27802780

2781-
pub(crate) fn is_dangling<T: ?Sized>(ptr: *mut T) -> bool {
2781+
pub(crate) fn is_dangling<T: ?Sized>(ptr: *const T) -> bool {
27822782
(ptr.cast::<()>()).addr() == usize::MAX
27832783
}
27842784

@@ -3003,7 +3003,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
30033003
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self {
30043004
// See Weak::as_ptr for context on how the input pointer is derived.
30053005

3006-
let ptr = if is_dangling(ptr as *mut T) {
3006+
let ptr = if is_dangling(ptr) {
30073007
// This is a dangling Weak.
30083008
ptr as *mut RcBox<T>
30093009
} else {

library/alloc/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2722,7 +2722,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
27222722
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Self {
27232723
// See Weak::as_ptr for context on how the input pointer is derived.
27242724

2725-
let ptr = if is_dangling(ptr as *mut T) {
2725+
let ptr = if is_dangling(ptr) {
27262726
// This is a dangling Weak.
27272727
ptr as *mut ArcInner<T>
27282728
} else {

0 commit comments

Comments
 (0)