diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-08-02 11:03:31 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-02 11:03:31 +0900 |
| commit | 0851841970f3bcc7616ff7f9c837e19d52c5e0dd (patch) | |
| tree | 3e70708aa9c43de006f2fc353afe903b63e99f41 | |
| parent | 0c9b35b8c726b679f4c9cb67d2936955515ce614 (diff) | |
| parent | 6aaa8327f9f47033f4958dbf634413ff0cd98a3e (diff) | |
| download | rust-0851841970f3bcc7616ff7f9c837e19d52c5e0dd.tar.gz rust-0851841970f3bcc7616ff7f9c837e19d52c5e0dd.zip | |
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`
| -rw-r--r-- | library/core/src/ptr/non_null.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 032df7f5a80..87c8674af0d 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -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")] |
