diff options
| author | Ralf Jung <post@ralfj.de> | 2019-08-07 11:59:23 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-08-11 12:04:49 +0200 |
| commit | c5a63566d6d8d70687410b41b6464bcef3ef89f3 (patch) | |
| tree | aef729d75f3b4194b49e9c14c686bee15428c733 | |
| parent | 3972d05fec01cd46c207f6e98aca5ee20102e17a (diff) | |
| download | rust-c5a63566d6d8d70687410b41b6464bcef3ef89f3.tar.gz rust-c5a63566d6d8d70687410b41b6464bcef3ef89f3.zip | |
allow the lint if a few UB-demonstrating doc tests
| -rw-r--r-- | src/libcore/mem/maybe_uninit.rs | 3 | ||||
| -rw-r--r-- | src/libcore/mem/mod.rs | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 8d064de6f47..1bbea02e0c7 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -13,6 +13,7 @@ use crate::mem::ManuallyDrop; /// ever gets used to access memory: /// /// ```rust,no_run +/// # #![allow(invalid_value)] /// use std::mem::{self, MaybeUninit}; /// /// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! @@ -27,6 +28,7 @@ use crate::mem::ManuallyDrop; /// always be `true` or `false`. Hence, creating an uninitialized `bool` is undefined behavior: /// /// ```rust,no_run +/// # #![allow(invalid_value)] /// use std::mem::{self, MaybeUninit}; /// /// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior! @@ -40,6 +42,7 @@ use crate::mem::ManuallyDrop; /// which otherwise can hold any *fixed* bit pattern: /// /// ```rust,no_run +/// # #![allow(invalid_value)] /// use std::mem::{self, MaybeUninit}; /// /// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index 86dae985fdb..16cfe0f7683 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -445,7 +445,8 @@ pub const fn needs_drop<T>() -> bool { /// /// *Incorrect* usage of this function: initializing a reference with zero. /// -/// ```no_run +/// ```rust,no_run +/// # #![allow(invalid_value)] /// use std::mem; /// /// let _x: &i32 = unsafe { mem::zeroed() }; // Undefined behavior! |
