1
Fork 0

fix lint doc

This commit is contained in:
Aliénore Bouttefeux 2021-04-08 12:09:32 +02:00
parent 3d215bdf42
commit 0531ed0b62

View file

@ -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))`.
///