Permit use of mem::uninitialized via allow(deprecated)
This commit is contained in:
parent
8a7dded1a2
commit
007d87f171
20 changed files with 30 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
#[allow(deprecated)]
|
||||
let xs: [u8; 4] = unsafe { mem::uninitialized() };
|
||||
let y = xs[0] + xs[1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// in a runtime panic.
|
||||
|
||||
#![feature(never_type)]
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::{mem, panic};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use std::mem;
|
|||
#[derive(Clone)]
|
||||
struct Foo;
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let _x: Foo = mem::uninitialized();
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ impl<U: Unsigned, B: Bit> Add<B0> for UInt<U, B> {
|
|||
impl<U: Unsigned> Add<U> for UTerm {
|
||||
type Output = U;
|
||||
fn add(self, _: U) -> Self::Output {
|
||||
#[allow(deprecated)]
|
||||
unsafe { ::std::mem::uninitialized() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use std::mem;
|
|||
|
||||
fn foo<const SIZE: usize>() {
|
||||
let arr: [u8; SIZE] = unsafe {
|
||||
#[allow(deprecated)]
|
||||
let mut array: [u8; SIZE] = mem::uninitialized();
|
||||
array
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(deprecated)]
|
||||
|
||||
enum Void {}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue