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
This commit is contained in:
Mara Bos 2021-09-03 13:30:47 +02:00 committed by GitHub
commit 80b572b5e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
use core::cell::Cell;
use core::cmp::Ordering;
use core::mem::MaybeUninit;
use core::result::Result::{Err, Ok};
#[test]
@ -2144,3 +2145,10 @@ fn test_slice_run_destructors() {
assert_eq!(x.get(), 1);
}
#[test]
fn test_slice_fill_with_uninit() {
// This should not UB. See #87891
let mut a = [MaybeUninit::<u8>::uninit(); 10];
a.fill(MaybeUninit::uninit());
}