Skip to content

Commit 157b76a

Browse files
committed
allow the lint if a few UB-demonstrating doc tests
1 parent b258ed5 commit 157b76a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/libcore/mem/maybe_uninit.rs

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::mem::ManuallyDrop;
1313
/// ever gets used to access memory:
1414
///
1515
/// ```rust,no_run
16+
/// # #![allow(invalid_value)]
1617
/// use std::mem::{self, MaybeUninit};
1718
///
1819
/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior!
@@ -27,6 +28,7 @@ use crate::mem::ManuallyDrop;
2728
/// always be `true` or `false`. Hence, creating an uninitialized `bool` is undefined behavior:
2829
///
2930
/// ```rust,no_run
31+
/// # #![allow(invalid_value)]
3032
/// use std::mem::{self, MaybeUninit};
3133
///
3234
/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior!
@@ -40,6 +42,7 @@ use crate::mem::ManuallyDrop;
4042
/// which otherwise can hold any *fixed* bit pattern:
4143
///
4244
/// ```rust,no_run
45+
/// # #![allow(invalid_value)]
4346
/// use std::mem::{self, MaybeUninit};
4447
///
4548
/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior!

src/libcore/mem/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ pub const fn needs_drop<T>() -> bool {
445445
///
446446
/// *Incorrect* usage of this function: initializing a reference with zero.
447447
///
448-
/// ```no_run
448+
/// ```rust,no_run
449+
/// # #![allow(invalid_value)]
449450
/// use std::mem;
450451
///
451452
/// let _x: &i32 = unsafe { mem::zeroed() }; // Undefined behavior!

0 commit comments

Comments
 (0)