Skip to content

Commit

Permalink
Rollup merge of #88507 - atsuzaki:slice-fill-maybeuninit-test, r=Ralf…
Browse files Browse the repository at this point in the history
…Jung

Add test case for using `slice::fill` with MaybeUninit

Adds test for #87891

Looks alright? `@RalfJung`
Fixes #87891
  • Loading branch information
m-ou-se authored Sep 3, 2021
2 parents 3ce205a + 5390ea4 commit 80b572b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/core/tests/slice.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use core::cell::Cell;
use core::cmp::Ordering;
use core::mem::MaybeUninit;
use core::result::Result::{Err, Ok};

#[test]
Expand Down Expand Up @@ -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());
}

0 comments on commit 80b572b

Please sign in to comment.