Skip to content

Commit b58f647

Browse files
committedFeb 21, 2024
rename ptr::invalid -> ptr::without_provenance
also introduce ptr::dangling matching NonNull::dangling
1 parent 1d447a9 commit b58f647

File tree

56 files changed

+303
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+303
-232
lines changed
 

‎compiler/rustc_arena/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<T> ArenaChunk<T> {
9595
unsafe {
9696
if mem::size_of::<T>() == 0 {
9797
// A pointer as large as possible for zero-sized elements.
98-
ptr::invalid_mut(!0)
98+
ptr::without_provenance_mut(!0)
9999
} else {
100100
self.start().add(self.storage.len())
101101
}

‎library/alloc/src/rc.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,7 +2804,9 @@ impl<T> Weak<T> {
28042804
#[must_use]
28052805
pub const fn new() -> Weak<T> {
28062806
Weak {
2807-
ptr: unsafe { NonNull::new_unchecked(ptr::invalid_mut::<RcBox<T>>(usize::MAX)) },
2807+
ptr: unsafe {
2808+
NonNull::new_unchecked(ptr::without_provenance_mut::<RcBox<T>>(usize::MAX))
2809+
},
28082810
alloc: Global,
28092811
}
28102812
}
@@ -2829,7 +2831,9 @@ impl<T, A: Allocator> Weak<T, A> {
28292831
#[unstable(feature = "allocator_api", issue = "32838")]
28302832
pub fn new_in(alloc: A) -> Weak<T, A> {
28312833
Weak {
2832-
ptr: unsafe { NonNull::new_unchecked(ptr::invalid_mut::<RcBox<T>>(usize::MAX)) },
2834+
ptr: unsafe {
2835+
NonNull::new_unchecked(ptr::without_provenance_mut::<RcBox<T>>(usize::MAX))
2836+
},
28332837
alloc,
28342838
}
28352839
}

0 commit comments

Comments
 (0)
Please sign in to comment.