File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -602,7 +602,7 @@ pub const fn without_provenance<T>(addr: usize) -> *const T {
602602 unsafe { mem:: transmute ( addr) }
603603}
604604
605- /// Creates a new pointer that is dangling, but well-aligned.
605+ /// Creates a new pointer that is dangling, but non-null and well-aligned.
606606///
607607/// This is useful for initializing types which lazily allocate, like
608608/// `Vec::new` does.
@@ -645,7 +645,7 @@ pub const fn without_provenance_mut<T>(addr: usize) -> *mut T {
645645 unsafe { mem:: transmute ( addr) }
646646}
647647
648- /// Creates a new pointer that is dangling, but well-aligned.
648+ /// Creates a new pointer that is dangling, but non-null and well-aligned.
649649///
650650/// This is useful for initializing types which lazily allocate, like
651651/// `Vec::new` does.
Original file line number Diff line number Diff line change @@ -107,9 +107,7 @@ impl<T: Sized> NonNull<T> {
107107 #[ must_use]
108108 #[ inline]
109109 pub const fn dangling ( ) -> Self {
110- // SAFETY: mem::align_of() returns a non-zero usize which is then casted
111- // to a *mut T. Therefore, `ptr` is not null and the conditions for
112- // calling new_unchecked() are respected.
110+ // SAFETY: ptr::dangling_mut() returns a non-null well-aligned pointer.
113111 unsafe {
114112 let ptr = crate :: ptr:: dangling_mut :: < T > ( ) ;
115113 NonNull :: new_unchecked ( ptr)
You can’t perform that action at this time.
0 commit comments