Skip to content

Commit 80b572b

Browse files
authored
Rollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=RalfJung
Add test case for using `slice::fill` with MaybeUninit Adds test for #87891 Looks alright? `@RalfJung` Fixes #87891
2 parents 3ce205a + 5390ea4 commit 80b572b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/core/tests/slice.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use core::cell::Cell;
22
use core::cmp::Ordering;
3+
use core::mem::MaybeUninit;
34
use core::result::Result::{Err, Ok};
45

56
#[test]
@@ -2144,3 +2145,10 @@ fn test_slice_run_destructors() {
21442145

21452146
assert_eq!(x.get(), 1);
21462147
}
2148+
2149+
#[test]
2150+
fn test_slice_fill_with_uninit() {
2151+
// This should not UB. See #87891
2152+
let mut a = [MaybeUninit::<u8>::uninit(); 10];
2153+
a.fill(MaybeUninit::uninit());
2154+
}

0 commit comments

Comments
 (0)