Skip to content

Commit 0531ed0

Browse files
committed
fix lint doc
1 parent 3d215bd commit 0531ed0

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

compiler/rustc_lint/src/builtin.rs

+7-18
Original file line numberDiff line numberDiff line change
@@ -2969,32 +2969,21 @@ declare_lint! {
29692969
/// which causes [undefined behavior].
29702970
///
29712971
/// ### Example
2972+
///
29722973
/// ```rust,no_run
2974+
/// # #![allow(unused)]
29732975
/// unsafe {
2974-
/// &*core::ptr::null::<i32>()
2975-
/// };
2976-
/// ```
2977-
/// ```rust,no_run
2978-
/// unsafe {
2979-
/// core::ptr::addr_of!(*std::ptr::null::<i32>())
2980-
/// };
2981-
/// ```
2982-
/// ```rust,no_run
2983-
/// unsafe {
2984-
/// *core::ptr::null::<i32>()
2985-
/// };
2986-
/// ```
2987-
/// ```rust,no_run
2988-
/// unsafe {
2989-
/// *(0 as *const i32)
2990-
/// };
2976+
/// let x = &*core::ptr::null::<i32>();
2977+
/// let x = core::ptr::addr_of!(*std::ptr::null::<i32>());
2978+
/// let x = *core::ptr::null::<i32>();
2979+
/// let x = *(0 as *const i32);
2980+
/// }
29912981
/// ```
29922982
///
29932983
/// {{produces}}
29942984
///
29952985
/// ### Explanation
29962986
///
2997-
///
29982987
/// Dereferencing a null pointer causes [undefined behavior] even as a place expression,
29992988
/// like `&*(0 as *const i32)` or `addr_of!(*(0 as *const i32))`.
30002989
///

0 commit comments

Comments
 (0)