Rollup merge of #87653 - RalfJung:dont-run-ub, r=kennytm

mark a UB doctest as no_run

See https://github.com/rust-lang/rust/pull/87547#discussion_r680334117
Cc `@GuillaumeGomez` `@kennytm`
This commit is contained in:
Yuki Okushi 2021-08-02 11:03:31 +09:00 committed by GitHub
commit 0851841970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,8 +173,14 @@ impl<T: ?Sized> NonNull<T> {
///
/// let mut x = 0u32;
/// let ptr = unsafe { NonNull::new_unchecked(&mut x as *mut _) };
/// ```
///
/// // NEVER DO THAT!!!
/// *Incorrect* usage of this function:
///
/// ```rust,no_run
/// use std::ptr::NonNull;
///
/// // 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")]