Skip to content

Commit 007d87f

Browse files
Permit use of mem::uninitialized via allow(deprecated)
1 parent 8a7dded commit 007d87f

20 files changed

+30
-9
lines changed

src/librustc_codegen_llvm/common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ impl CodegenCx<'ll, 'tcx> {
170170
pub fn const_get_real(&self, v: &'ll Value) -> Option<(f64, bool)> {
171171
unsafe {
172172
if self.is_const_real(v) {
173+
#[allow(deprecated)]
173174
let mut loses_info: llvm::Bool = ::std::mem::uninitialized();
174175
let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info);
175176
let loses_info = if loses_info == 1 { true } else { false };

src/libstd/io/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<
4444
where R: Read, W: Write
4545
{
4646
let mut buf = unsafe {
47+
#[allow(deprecated)]
4748
let mut buf: [u8; super::DEFAULT_BUF_SIZE] = mem::uninitialized();
4849
reader.initializer().initialize(&mut buf);
4950
buf

src/libstd/sys/cloudabi/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(deprecated)] // mem::uninitialized
2+
13
use crate::io::ErrorKind;
24
use crate::mem;
35

src/libstd/sys/sgx/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! This module contains the facade (aka platform-specific) implementations of
44
//! OS level functionality for Fortanix SGX.
55
6+
#![allow(deprecated)]
7+
68
use crate::io::ErrorKind;
79
use crate::os::raw::c_char;
810
use crate::sync::atomic::{AtomicBool, Ordering};

src/libterm/win.rs

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ impl<T: Write + Send + 'static> WinConsole<T> {
108108
let fg;
109109
let bg;
110110
unsafe {
111+
#[allow(deprecated)]
111112
let mut buffer_info = ::std::mem::uninitialized();
112113
if GetConsoleScreenBufferInfo(GetStdHandle(-11i32 as DWORD), &mut buffer_info) != 0 {
113114
fg = bits_to_color(buffer_info.wAttributes);
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::mem;
22

33
fn main() {
4+
#[allow(deprecated)]
45
let xs: [u8; 4] = unsafe { mem::uninitialized() };
56
let y = xs[0] + xs[1];
67
}

src/test/run-pass/for-loop-while/for-loop-has-unit-body.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
fn main() {
33
// Check that the tail statement in the body unifies with something
44
for _ in 0..3 {
5+
#[allow(deprecated)]
56
unsafe { std::mem::uninitialized() }
67
}
78

src/test/run-pass/issues/issue-58212.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ trait FromUnchecked {
44

55
impl FromUnchecked for [u8; 1] {
66
unsafe fn from_unchecked() {
7+
#[allow(deprecated)]
78
let mut array: Self = std::mem::uninitialized();
89
let _ptr = &mut array as *mut [u8] as *mut u8;
910
}

src/test/run-pass/panic-uninitialized-zeroed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// in a runtime panic.
44

55
#![feature(never_type)]
6+
#![allow(deprecated)]
67

78
use std::{mem, panic};
89

src/test/run-pass/stack-probes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ fn main() {
4949
#[allow(unconditional_recursion)]
5050
fn recurse(array: &[u64]) {
5151
unsafe { black_box(array.as_ptr() as u64); }
52+
#[allow(deprecated)]
5253
let local: [_; 1024] = unsafe { mem::uninitialized() };
5354
recurse(&local);
5455
}

src/test/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ fn main() {
6969
unsafe {
7070
// This should be safe, because we don't match on it unless it's fully formed,
7171
// and it doesn't have a destructor.
72+
#[allow(deprecated)]
7273
let mut dest: MyEnum = mem::uninitialized();
7374
while buf.len() > 0 {
7475
match parse_my_enum(&mut dest, &mut buf) {

src/test/run-pass/structs-enums/enum-non-c-like-repr-c.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ fn main() {
6969
unsafe {
7070
// This should be safe, because we don't match on it unless it's fully formed,
7171
// and it doesn't have a destructor.
72+
#[allow(deprecated)]
7273
let mut dest: MyEnum = mem::uninitialized();
7374
while buf.len() > 0 {
7475
match parse_my_enum(&mut dest, &mut buf) {

src/test/run-pass/structs-enums/enum-non-c-like-repr-int.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn main() {
6565
unsafe {
6666
// This should be safe, because we don't match on it unless it's fully formed,
6767
// and it doesn't have a destructor.
68+
#[allow(deprecated)]
6869
let mut dest: MyEnum = mem::uninitialized();
6970
while buf.len() > 0 {
7071
match parse_my_enum(&mut dest, &mut buf) {

src/test/run-pass/uninit-empty-types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::mem;
77
#[derive(Clone)]
88
struct Foo;
99

10+
#[allow(deprecated)]
1011
pub fn main() {
1112
unsafe {
1213
let _x: Foo = mem::uninitialized();

src/test/rustdoc/issue-52873.rs

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl<U: Unsigned, B: Bit> Add<B0> for UInt<U, B> {
105105
impl<U: Unsigned> Add<U> for UTerm {
106106
type Output = U;
107107
fn add(self, _: U) -> Self::Output {
108+
#[allow(deprecated)]
108109
unsafe { ::std::mem::uninitialized() }
109110
}
110111
}

src/test/ui/const-generics/issue-61422.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::mem;
77

88
fn foo<const SIZE: usize>() {
99
let arr: [u8; SIZE] = unsafe {
10+
#[allow(deprecated)]
1011
let mut array: [u8; SIZE] = mem::uninitialized();
1112
array
1213
};

src/test/ui/issues/issue-48131.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This note is annotated because the purpose of the test
22
// is to ensure that certain other notes are not generated.
33
#![deny(unused_unsafe)] //~ NOTE
4+
#![allow(deprecated)]
45

56
// (test that no note is generated on this unsafe fn)
67
pub unsafe fn a() {

src/test/ui/issues/issue-48131.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unnecessary `unsafe` block
2-
--> $DIR/issue-48131.rs:8:9
2+
--> $DIR/issue-48131.rs:9:9
33
|
44
LL | unsafe { /* unnecessary */ }
55
| ^^^^^^ unnecessary `unsafe` block
@@ -11,7 +11,7 @@ LL | #![deny(unused_unsafe)]
1111
| ^^^^^^^^^^^^^
1212

1313
error: unnecessary `unsafe` block
14-
--> $DIR/issue-48131.rs:19:13
14+
--> $DIR/issue-48131.rs:20:13
1515
|
1616
LL | unsafe { /* unnecessary */ }
1717
| ^^^^^^ unnecessary `unsafe` block

src/test/ui/uninhabited/uninhabited-matches-feature-gated.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(deprecated)]
2+
13
enum Void {}
24

35
fn main() {

src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
2-
--> $DIR/uninhabited-matches-feature-gated.rs:5:19
2+
--> $DIR/uninhabited-matches-feature-gated.rs:7:19
33
|
44
LL | let _ = match x {
55
| ^ pattern `Err(_)` not covered
66
|
77
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
88

99
error[E0004]: non-exhaustive patterns: type `&Void` is non-empty
10-
--> $DIR/uninhabited-matches-feature-gated.rs:10:19
10+
--> $DIR/uninhabited-matches-feature-gated.rs:12:19
1111
|
1212
LL | let _ = match x {};
1313
| ^
1414
|
1515
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
1616

1717
error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty
18-
--> $DIR/uninhabited-matches-feature-gated.rs:13:19
18+
--> $DIR/uninhabited-matches-feature-gated.rs:15:19
1919
|
2020
LL | let _ = match x {};
2121
| ^
2222
|
2323
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
2424

2525
error[E0004]: non-exhaustive patterns: type `[Void; 1]` is non-empty
26-
--> $DIR/uninhabited-matches-feature-gated.rs:16:19
26+
--> $DIR/uninhabited-matches-feature-gated.rs:18:19
2727
|
2828
LL | let _ = match x {};
2929
| ^
3030
|
3131
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
3232

3333
error[E0004]: non-exhaustive patterns: `&[_]` not covered
34-
--> $DIR/uninhabited-matches-feature-gated.rs:19:19
34+
--> $DIR/uninhabited-matches-feature-gated.rs:21:19
3535
|
3636
LL | let _ = match x {
3737
| ^ pattern `&[_]` not covered
3838
|
3939
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
4040

4141
error[E0004]: non-exhaustive patterns: `Err(_)` not covered
42-
--> $DIR/uninhabited-matches-feature-gated.rs:27:19
42+
--> $DIR/uninhabited-matches-feature-gated.rs:29:19
4343
|
4444
LL | let _ = match x {
4545
| ^ pattern `Err(_)` not covered
4646
|
4747
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
4848

4949
error[E0005]: refutable pattern in local binding: `Err(_)` not covered
50-
--> $DIR/uninhabited-matches-feature-gated.rs:32:9
50+
--> $DIR/uninhabited-matches-feature-gated.rs:34:9
5151
|
5252
LL | let Ok(x) = x;
5353
| ^^^^^ pattern `Err(_)` not covered

0 commit comments

Comments
 (0)