Skip to content

Commit 0851841

Browse files
authored
Rollup merge of #87653 - RalfJung:dont-run-ub, r=kennytm
mark a UB doctest as no_run See #87547 (comment) Cc `@GuillaumeGomez` `@kennytm`
2 parents 0c9b35b + 6aaa832 commit 0851841

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/core/src/ptr/non_null.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ impl<T: ?Sized> NonNull<T> {
173173
///
174174
/// let mut x = 0u32;
175175
/// let ptr = unsafe { NonNull::new_unchecked(&mut x as *mut _) };
176+
/// ```
177+
///
178+
/// *Incorrect* usage of this function:
179+
///
180+
/// ```rust,no_run
181+
/// use std::ptr::NonNull;
176182
///
177-
/// // NEVER DO THAT!!!
183+
/// // NEVER DO THAT!!! This is undefined behavior. ⚠️
178184
/// let ptr = unsafe { NonNull::<u32>::new_unchecked(std::ptr::null_mut()) };
179185
/// ```
180186
#[stable(feature = "nonnull", since = "1.25.0")]

0 commit comments

Comments
 (0)