about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-08 12:09:32 +0200
committerAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-04-08 12:09:32 +0200
commit0531ed0b6220257d7c79405ca7d81d9fe66976be (patch)
treecfb835db4b6d0aecbce1449436d88db1526bdf82
parent3d215bdf42514311e48f5dc1cbf71cbd3d74e732 (diff)
downloadrust-0531ed0b6220257d7c79405ca7d81d9fe66976be.tar.gz
rust-0531ed0b6220257d7c79405ca7d81d9fe66976be.zip
fix lint doc
-rw-r--r--compiler/rustc_lint/src/builtin.rs25
1 files changed, 7 insertions, 18 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs
index e449cd8c755..905a808f51f 100644
--- a/compiler/rustc_lint/src/builtin.rs
+++ b/compiler/rustc_lint/src/builtin.rs
@@ -2969,32 +2969,21 @@ declare_lint! {
     /// which causes [undefined behavior].
     ///
     /// ### Example
+    ///
     /// ```rust,no_run
+    /// # #![allow(unused)]
     /// unsafe {
-    ///     &*core::ptr::null::<i32>()
-    /// };
-    /// ```
-    /// ```rust,no_run
-    /// unsafe {
-    ///     core::ptr::addr_of!(*std::ptr::null::<i32>())
-    /// };
-    /// ```
-    /// ```rust,no_run
-    /// unsafe {
-    ///     *core::ptr::null::<i32>()
-    /// };
-    /// ```
-    /// ```rust,no_run
-    /// unsafe {
-    ///     *(0 as *const i32)
-    /// };
+    ///     let x = &*core::ptr::null::<i32>();
+    ///     let x = core::ptr::addr_of!(*std::ptr::null::<i32>());
+    ///     let x = *core::ptr::null::<i32>();
+    ///     let x = *(0 as *const i32);
+    /// }
     /// ```
     ///
     /// {{produces}}
     ///
     /// ### Explanation
     ///
-    ///
     /// Dereferencing a null pointer causes [undefined behavior] even as a place expression,
     /// like `&*(0 as *const i32)` or `addr_of!(*(0 as *const i32))`.
     ///