diff --git a/alacritty_terminal/src/term/cell.rs b/alacritty_terminal/src/term/cell.rs index 5e2762d..8d1b135 100644 --- a/alacritty_terminal/src/term/cell.rs +++ b/alacritty_terminal/src/term/cell.rs @@ -138,14 +138,14 @@ impl Cell { #[inline] pub fn chars(&self) -> [char; MAX_ZEROWIDTH_CHARS + 1] { unsafe { - let mut chars = [std::mem::uninitialized(); MAX_ZEROWIDTH_CHARS + 1]; - std::ptr::write(&mut chars[0], self.c); + let mut chars = [std::mem::MaybeUninit::uninit(); MAX_ZEROWIDTH_CHARS + 1]; + std::ptr::write(chars[0].as_mut_ptr(), self.c); std::ptr::copy_nonoverlapping( - self.extra.as_ptr(), + self.extra.as_ptr() as *mut std::mem::MaybeUninit, chars.as_mut_ptr().offset(1), self.extra.len(), ); - chars + std::mem::transmute(chars) } } diff --git a/alacritty_terminal/src/term/color.rs b/alacritty_terminal/src/term/color.rs index 877d89e..f2db335 100644 --- a/alacritty_terminal/src/term/color.rs +++ b/alacritty_terminal/src/term/color.rs @@ -143,7 +143,7 @@ pub struct List([Rgb; COUNT]); impl<'a> From<&'a Colors> for List { fn from(colors: &Colors) -> List { // Type inference fails without this annotation - let mut list: List = unsafe { ::std::mem::uninitialized() }; + let mut list = List([Rgb::default(); COUNT]); list.fill_named(colors); list.fill_cube(colors); diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index 8ed8ba0..e666eeb 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -13,7 +13,6 @@ // limitations under the License. // //! tty related functionality -//! use crate::config::{Config, Shell}; use crate::display::OnResize; @@ -36,6 +35,7 @@ use std::os::unix::{ use std::process::{Child, Command, Stdio}; use std::ptr; use std::sync::atomic::{AtomicUsize, Ordering}; +use std::mem::MaybeUninit; /// Process ID of child process /// @@ -91,15 +91,16 @@ struct Passwd<'a> { /// If `buf` is changed while `Passwd` is alive, bad thing will almost certainly happen. fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd<'_> { // Create zeroed passwd struct - let mut entry: libc::passwd = unsafe { ::std::mem::uninitialized() }; + let mut entry: MaybeUninit = MaybeUninit::uninit(); let mut res: *mut libc::passwd = ptr::null_mut(); // Try and read the pw file. let uid = unsafe { libc::getuid() }; let status = unsafe { - libc::getpwuid_r(uid, &mut entry, buf.as_mut_ptr() as *mut _, buf.len(), &mut res) + libc::getpwuid_r(uid, entry.as_mut_ptr(), buf.as_mut_ptr() as *mut _, buf.len(), &mut res) }; + let entry = unsafe { entry.assume_init() }; if status < 0 { die!("getpwuid_r failed");