about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-07-31 11:37:48 +0200
committerRalf Jung <post@ralfj.de>2021-07-31 11:37:48 +0200
commit6aaa8327f9f47033f4958dbf634413ff0cd98a3e (patch)
treea542f4d10bf68ebd56a52faa2f878216502b227a
parent6b0b07d41f07e1ba5808693d900903499ccf7a32 (diff)
downloadrust-6aaa8327f9f47033f4958dbf634413ff0cd98a3e.tar.gz
rust-6aaa8327f9f47033f4958dbf634413ff0cd98a3e.zip
mark a UB doctest as no_run
-rw-r--r--library/core/src/ptr/non_null.rs8
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")]