Stylo: replace uses of mem::uninitialized with MaybeUninit

MozReview-Commit-ID: KGhYL6DJRaR
This commit is contained in:
Simon Sapin 2019-07-06 18:16:30 +02:00
parent 00b3fb49c4
commit 17ec774a49
9 changed files with 60 additions and 68 deletions

View file

@ -202,7 +202,8 @@ impl WeakAtom {
where
F: FnOnce(&str) -> Output,
{
let mut buffer: [u8; 64] = unsafe { mem::uninitialized() };
let mut buffer = mem::MaybeUninit::<[u8; 64]>::uninit();
let buffer = unsafe { &mut *buffer.as_mut_ptr() };
// The total string length in utf16 is going to be less than or equal
// the slice length (each utf16 character is going to take at least one
@ -271,7 +272,8 @@ impl WeakAtom {
}
let slice = self.as_slice();
let mut buffer: [u16; 64] = unsafe { mem::uninitialized() };
let mut buffer = mem::MaybeUninit::<[u16; 64]>::uninit();
let buffer = unsafe { &mut *buffer.as_mut_ptr() };
let mut vec;
let mutable_slice = if let Some(buffer_prefix) = buffer.get_mut(..slice.len()) {
buffer_prefix.copy_from_slice(slice);