Skip to content

Commit

Permalink
mark a UB doctest as no_run
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 31, 2021
1 parent 6b0b07d commit 6aaa832
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/core/src/ptr/non_null.rs
Expand Up @@ -173,8 +173,14 @@ impl<T: ?Sized> NonNull<T> {
///
/// let mut x = 0u32;
/// let ptr = unsafe { NonNull::new_unchecked(&mut x as *mut _) };
/// ```
///
/// *Incorrect* usage of this function:
///
/// ```rust,no_run
/// use std::ptr::NonNull;
///
/// // NEVER DO THAT!!!
/// // NEVER DO THAT!!! This is undefined behavior. ⚠️
/// let ptr = unsafe { NonNull::<u32>::new_unchecked(std::ptr::null_mut()) };
/// ```
#[stable(feature = "nonnull", since = "1.25.0")]
Expand Down

0 comments on commit 6aaa832

Please sign in to comment.