Remove use of mem::uninitialized in libterm crate

This commit is contained in:
Lzu Tao 2019-07-05 18:59:56 +00:00
parent 05c1e92787
commit 42c3d37145

View File

@ -2,8 +2,6 @@
// FIXME (#13400): this is only a tiny fraction of the Windows console api // FIXME (#13400): this is only a tiny fraction of the Windows console api
extern crate libc;
use std::io; use std::io;
use std::io::prelude::*; use std::io::prelude::*;
@ -122,12 +120,17 @@ impl<T: Write + Send + 'static> WinConsole<T> {
/// Returns `None` whenever the terminal cannot be created for some reason. /// Returns `None` whenever the terminal cannot be created for some reason.
pub fn new(out: T) -> io::Result<WinConsole<T>> { pub fn new(out: T) -> io::Result<WinConsole<T>> {
use std::mem::MaybeUninit;
let fg; let fg;
let bg; let bg;
unsafe { unsafe {
#[allow(deprecated)] let mut buffer_info = MaybeUninit::<CONSOLE_SCREEN_BUFFER_INFO>::uninit();
let mut buffer_info = ::std::mem::uninitialized(); if GetConsoleScreenBufferInfo(
if GetConsoleScreenBufferInfo(GetStdHandle(-11i32 as DWORD), &mut buffer_info) != 0 { GetStdHandle(-11i32 as DWORD),
buffer_info.as_mut_ptr()
) != 0 {
let buffer_info = buffer_info.assume_init() ;
fg = bits_to_color(buffer_info.wAttributes); fg = bits_to_color(buffer_info.wAttributes);
bg = bits_to_color(buffer_info.wAttributes >> 4); bg = bits_to_color(buffer_info.wAttributes >> 4);
} else { } else {