]> git.lizzy.rs Git - rust.git/commitdiff
Permit use of mem::uninitialized via allow(deprecated)
authorMark Rousskov <mark.simulacrum@gmail.com>
Thu, 4 Jul 2019 15:24:56 +0000 (11:24 -0400)
committerMark Rousskov <mark.simulacrum@gmail.com>
Fri, 5 Jul 2019 01:01:35 +0000 (21:01 -0400)
20 files changed:
src/librustc_codegen_llvm/common.rs
src/libstd/io/util.rs
src/libstd/sys/cloudabi/mod.rs
src/libstd/sys/sgx/mod.rs
src/libterm/win.rs
src/test/run-make-fulldeps/sanitizer-memory/uninit.rs
src/test/run-pass/for-loop-while/for-loop-has-unit-body.rs
src/test/run-pass/issues/issue-58212.rs
src/test/run-pass/panic-uninitialized-zeroed.rs
src/test/run-pass/stack-probes.rs
src/test/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs
src/test/run-pass/structs-enums/enum-non-c-like-repr-c.rs
src/test/run-pass/structs-enums/enum-non-c-like-repr-int.rs
src/test/run-pass/uninit-empty-types.rs
src/test/rustdoc/issue-52873.rs
src/test/ui/const-generics/issue-61422.rs
src/test/ui/issues/issue-48131.rs
src/test/ui/issues/issue-48131.stderr
src/test/ui/uninhabited/uninhabited-matches-feature-gated.rs
src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr

index f21f203fcc99f0abea1f89e242014445b3dc37a5..9fdc93c3ff0f3e01ce3586347f1c30d7a6494bc4 100644 (file)
@@ -170,6 +170,7 @@ pub fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
     pub fn const_get_real(&self, v: &'ll Value) -> Option<(f64, bool)> {
         unsafe {
             if self.is_const_real(v) {
+                #[allow(deprecated)]
                 let mut loses_info: llvm::Bool = ::std::mem::uninitialized();
                 let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info);
                 let loses_info = if loses_info == 1 { true } else { false };
index 7c4eae6512df4822a448efb3f65967de69eb868d..2bfd3e4ad20e3d29170370a849b4705ccfa3f0f5 100644 (file)
@@ -44,6 +44,7 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<
     where R: Read, W: Write
 {
     let mut buf = unsafe {
+        #[allow(deprecated)]
         let mut buf: [u8; super::DEFAULT_BUF_SIZE] = mem::uninitialized();
         reader.initializer().initialize(&mut buf);
         buf
index c3b8bbd042606e17e1581d236a7fdb0975aebe21..3fef7552259c86eb52ac0c38b7d0d370f049f591 100644 (file)
@@ -1,3 +1,5 @@
+#![allow(deprecated)] // mem::uninitialized
+
 use crate::io::ErrorKind;
 use crate::mem;
 
index 01f5536ed7a6594a614d77c0896fbab98aa1883a..3bf9ecf40808be426f49b9f531e95566609780e0 100644 (file)
@@ -3,6 +3,8 @@
 //! This module contains the facade (aka platform-specific) implementations of
 //! OS level functionality for Fortanix SGX.
 
+#![allow(deprecated)]
+
 use crate::io::ErrorKind;
 use crate::os::raw::c_char;
 use crate::sync::atomic::{AtomicBool, Ordering};
index 6d42b01337ed531bd36e2c323a5effcbd9a7a548..14ea68d3788785246dd8458622893daf57a387cd 100644 (file)
@@ -108,6 +108,7 @@ pub fn new(out: T) -> io::Result<WinConsole<T>> {
         let fg;
         let bg;
         unsafe {
+            #[allow(deprecated)]
             let mut buffer_info = ::std::mem::uninitialized();
             if GetConsoleScreenBufferInfo(GetStdHandle(-11i32 as DWORD), &mut buffer_info) != 0 {
                 fg = bits_to_color(buffer_info.wAttributes);
index 163e2c5a4625f7014e014fecd04612ab826dc266..cb857e3bc38d352561278f03ec51216deba01f94 100644 (file)
@@ -1,6 +1,7 @@
 use std::mem;
 
 fn main() {
+    #[allow(deprecated)]
     let xs: [u8; 4] = unsafe { mem::uninitialized() };
     let y = xs[0] + xs[1];
 }
index 009c59f2fa43dfe96cfbd0bdf17159450b9cfb71..38c34d2dc2e6f8fbc7802b706aa4267a7418d977 100644 (file)
@@ -2,6 +2,7 @@
 fn main() {
     // Check that the tail statement in the body unifies with something
     for _ in 0..3 {
+        #[allow(deprecated)]
         unsafe { std::mem::uninitialized() }
     }
 
index 76437630309af1603364579864c03d0eb304c236..d4ce6496cae7733437612843ef850434a1b6d3c2 100644 (file)
@@ -4,6 +4,7 @@ trait FromUnchecked {
 
 impl FromUnchecked for [u8; 1] {
     unsafe fn from_unchecked() {
+        #[allow(deprecated)]
         let mut array: Self = std::mem::uninitialized();
         let _ptr = &mut array as *mut [u8] as *mut u8;
     }
index 4ca4b407bd4ff2b70ca60e3aed042874bc8efcec..5026ad1ccd4ceae68cd31fdeab74f2c81707d7a5 100644 (file)
@@ -3,6 +3,7 @@
 // in a runtime panic.
 
 #![feature(never_type)]
+#![allow(deprecated)]
 
 use std::{mem, panic};
 
index 92a0cc3a07b5211d629e9d23f5ed435f0e126a97..773d0ace90ed9dbc25792c4097c68e45768645d1 100644 (file)
@@ -49,6 +49,7 @@ fn main() {
 #[allow(unconditional_recursion)]
 fn recurse(array: &[u64]) {
     unsafe { black_box(array.as_ptr() as u64); }
+    #[allow(deprecated)]
     let local: [_; 1024] = unsafe { mem::uninitialized() };
     recurse(&local);
 }
index c971f567d954214ed134f171d88532fc34ebd3b4..78d8e5e3a5dbf39e9abf8059883df24647bdf652 100644 (file)
@@ -69,6 +69,7 @@ fn main() {
     unsafe {
         // This should be safe, because we don't match on it unless it's fully formed,
         // and it doesn't have a destructor.
+        #[allow(deprecated)]
         let mut dest: MyEnum = mem::uninitialized();
         while buf.len() > 0 {
             match parse_my_enum(&mut dest, &mut buf) {
index 57ccf11450913a3f458c2577d00ea989f44b9e4a..1209533efda82097f7564bfa2e4f9294398e83d5 100644 (file)
@@ -69,6 +69,7 @@ fn main() {
     unsafe {
         // This should be safe, because we don't match on it unless it's fully formed,
         // and it doesn't have a destructor.
+        #[allow(deprecated)]
         let mut dest: MyEnum = mem::uninitialized();
         while buf.len() > 0 {
             match parse_my_enum(&mut dest, &mut buf) {
index d297c895da5632dc5a61f0d186272a74bcde70fd..5dd9c1863d62da2b00b5343e8c4b35d956c59803 100644 (file)
@@ -65,6 +65,7 @@ fn main() {
     unsafe {
         // This should be safe, because we don't match on it unless it's fully formed,
         // and it doesn't have a destructor.
+        #[allow(deprecated)]
         let mut dest: MyEnum = mem::uninitialized();
         while buf.len() > 0 {
             match parse_my_enum(&mut dest, &mut buf) {
index b59971b3498027cdfef01442e9e2d4cf8d6ff98f..4bc247a3dcab5ba6a13b706e32c710d95e303bf5 100644 (file)
@@ -7,6 +7,7 @@
 #[derive(Clone)]
 struct Foo;
 
+#[allow(deprecated)]
 pub fn main() {
     unsafe {
         let _x: Foo = mem::uninitialized();
index 9138dd50defa06146503c5691decd12b78a07ba0..653c004c04b231c2606ce5f879dca7d4fb0b8d4c 100644 (file)
@@ -105,6 +105,7 @@ fn add(self, _: B0) -> Self::Output {
 impl<U: Unsigned> Add<U> for UTerm {
     type Output = U;
     fn add(self, _: U) -> Self::Output {
+        #[allow(deprecated)]
         unsafe { ::std::mem::uninitialized() }
     }
 }
index 3ccf38e5619775499121eb5669eda91826931bb9..68e5a52e0ac5cba18c9873560dbf5a86768df1b0 100644 (file)
@@ -7,6 +7,7 @@
 
 fn foo<const SIZE: usize>() {
     let arr: [u8; SIZE] = unsafe {
+        #[allow(deprecated)]
         let mut array: [u8; SIZE] = mem::uninitialized();
         array
     };
index b3cc350acf532c8ddd2c065ebbd90734656e7bab..c8540729352b270111be4af7913aa6e94d55972b 100644 (file)
@@ -1,6 +1,7 @@
 // This note is annotated because the purpose of the test
 // is to ensure that certain other notes are not generated.
 #![deny(unused_unsafe)] //~ NOTE
+#![allow(deprecated)]
 
 // (test that no note is generated on this unsafe fn)
 pub unsafe fn a() {
index adc36e266c2712450b8b6dba1eec3f2691491794..6df065b9807f2dff91c3f1c6cc3705c471967851 100644 (file)
@@ -1,5 +1,5 @@
 error: unnecessary `unsafe` block
-  --> $DIR/issue-48131.rs:8:9
+  --> $DIR/issue-48131.rs:9:9
    |
 LL |         unsafe { /* unnecessary */ }
    |         ^^^^^^ unnecessary `unsafe` block
@@ -11,7 +11,7 @@ LL | #![deny(unused_unsafe)]
    |         ^^^^^^^^^^^^^
 
 error: unnecessary `unsafe` block
-  --> $DIR/issue-48131.rs:19:13
+  --> $DIR/issue-48131.rs:20:13
    |
 LL |             unsafe { /* unnecessary */ }
    |             ^^^^^^ unnecessary `unsafe` block
index 38a52d5860d4b667ee83e1bb79a84a3c98dd9e0f..a5360fa13c4ea22f730ed317413532b976db2976 100644 (file)
@@ -1,3 +1,5 @@
+#![allow(deprecated)]
+
 enum Void {}
 
 fn main() {
index de7a963577085e04d8443ebe1d1a2ed9fc4be155..25519ab2d6a7d1cfc9130988a68bd7df10b6be6e 100644 (file)
@@ -1,5 +1,5 @@
 error[E0004]: non-exhaustive patterns: `Err(_)` not covered
-  --> $DIR/uninhabited-matches-feature-gated.rs:5:19
+  --> $DIR/uninhabited-matches-feature-gated.rs:7:19
    |
 LL |     let _ = match x {
    |                   ^ pattern `Err(_)` not covered
@@ -7,7 +7,7 @@ LL |     let _ = match x {
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0004]: non-exhaustive patterns: type `&Void` is non-empty
-  --> $DIR/uninhabited-matches-feature-gated.rs:10:19
+  --> $DIR/uninhabited-matches-feature-gated.rs:12:19
    |
 LL |     let _ = match x {};
    |                   ^
@@ -15,7 +15,7 @@ LL |     let _ = match x {};
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty
-  --> $DIR/uninhabited-matches-feature-gated.rs:13:19
+  --> $DIR/uninhabited-matches-feature-gated.rs:15:19
    |
 LL |     let _ = match x {};
    |                   ^
@@ -23,7 +23,7 @@ LL |     let _ = match x {};
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0004]: non-exhaustive patterns: type `[Void; 1]` is non-empty
-  --> $DIR/uninhabited-matches-feature-gated.rs:16:19
+  --> $DIR/uninhabited-matches-feature-gated.rs:18:19
    |
 LL |     let _ = match x {};
    |                   ^
@@ -31,7 +31,7 @@ LL |     let _ = match x {};
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0004]: non-exhaustive patterns: `&[_]` not covered
-  --> $DIR/uninhabited-matches-feature-gated.rs:19:19
+  --> $DIR/uninhabited-matches-feature-gated.rs:21:19
    |
 LL |     let _ = match x {
    |                   ^ pattern `&[_]` not covered
@@ -39,7 +39,7 @@ LL |     let _ = match x {
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0004]: non-exhaustive patterns: `Err(_)` not covered
-  --> $DIR/uninhabited-matches-feature-gated.rs:27:19
+  --> $DIR/uninhabited-matches-feature-gated.rs:29:19
    |
 LL |     let _ = match x {
    |                   ^ pattern `Err(_)` not covered
@@ -47,7 +47,7 @@ LL |     let _ = match x {
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
 error[E0005]: refutable pattern in local binding: `Err(_)` not covered
-  --> $DIR/uninhabited-matches-feature-gated.rs:32:9
+  --> $DIR/uninhabited-matches-feature-gated.rs:34:9
    |
 LL |     let Ok(x) = x;
    |         ^^^^^ pattern `Err(_)` not covered