Skip to content

Commit 8cecac2

Browse files
committed
Add test case for using slice::fill with MaybeUninit
1 parent 6cfa773 commit 8cecac2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/core/tests/slice.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,3 +2144,12 @@ fn test_slice_run_destructors() {
21442144

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

0 commit comments

Comments
 (0)