File tree 2 files changed +3
-5
lines changed
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 {
602
602
unsafe { mem:: transmute ( addr) }
603
603
}
604
604
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.
606
606
///
607
607
/// This is useful for initializing types which lazily allocate, like
608
608
/// `Vec::new` does.
@@ -645,7 +645,7 @@ pub const fn without_provenance_mut<T>(addr: usize) -> *mut T {
645
645
unsafe { mem:: transmute ( addr) }
646
646
}
647
647
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.
649
649
///
650
650
/// This is useful for initializing types which lazily allocate, like
651
651
/// `Vec::new` does.
Original file line number Diff line number Diff line change @@ -107,9 +107,7 @@ impl<T: Sized> NonNull<T> {
107
107
#[ must_use]
108
108
#[ inline]
109
109
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.
113
111
unsafe {
114
112
let ptr = crate :: ptr:: dangling_mut :: < T > ( ) ;
115
113
NonNull :: new_unchecked ( ptr)
You can’t perform that action at this time.
0 commit comments