diff options
| author | Katherine Philip <kurerunoshikaku@yahoo.com> | 2021-08-30 13:19:50 -0700 |
|---|---|---|
| committer | Katherine Philip <kurerunoshikaku@yahoo.com> | 2021-08-30 13:20:11 -0700 |
| commit | 8cecac260298a9b096e347a0489c64aafcd07ca1 (patch) | |
| tree | d43f32c260a64bc92d3ff16eefcbfb47877bcb3b | |
| parent | 6cfa773583bb5123e630668f5bfe466716225546 (diff) | |
Add test case for using `slice::fill` with MaybeUninit
| -rw-r--r-- | library/core/tests/slice.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 43e2af3eb18..a6c7794c150 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -2144,3 +2144,12 @@ fn test_slice_run_destructors() { assert_eq!(x.get(), 1); } + +#[test] +fn test_slice_fill_with_uninit() { + // This should not UB. See #87891 + use core::mem::MaybeUninit; + + let mut a = [MaybeUninit::<u8>::uninit(); 10]; + a.fill(MaybeUninit::uninit()); +} |
