1
Fork 0

Use 'error-pattern' in ui test

This commit is contained in:
Albin Hedman 2020-12-07 21:26:09 +01:00
parent bdda98aaba
commit 69ab0bcabf
2 changed files with 6 additions and 17 deletions

View file

@ -1,11 +1,13 @@
// error-pattern: any use of this value will cause an error
#![feature(never_type)]
#![feature(const_maybe_uninit_assume_init)]
#[allow(invalid_value)]
fn main() {
use std::mem::MaybeUninit;
const _BAD: () = unsafe {
MaybeUninit::<!>::uninit().assume_init();
//~^ WARN: the type `!` does not permit being left uninitialized
};
}

View file

@ -6,29 +6,16 @@ LL | intrinsics::assert_inhabited::<T>();
| |
| attempted to instantiate uninhabited type `!`
| inside `MaybeUninit::<!>::assume_init` at $SRC_DIR/core/src/mem/maybe_uninit.rs:LL:COL
| inside `_BAD` at $DIR/assume-type-intrinsics.rs:8:9
| inside `_BAD` at $DIR/assume-type-intrinsics.rs:11:9
|
::: $DIR/assume-type-intrinsics.rs:7:5
::: $DIR/assume-type-intrinsics.rs:10:5
|
LL | / const _BAD: () = unsafe {
LL | | MaybeUninit::<!>::uninit().assume_init();
LL | |
LL | | };
| |______-
|
= note: `#[deny(const_err)]` on by default
warning: the type `!` does not permit being left uninitialized
--> $DIR/assume-type-intrinsics.rs:8:9
|
LL | MaybeUninit::<!>::uninit().assume_init();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: `#[warn(invalid_value)]` on by default
= note: the `!` type has no valid value
error: aborting due to previous error; 1 warning emitted
error: aborting due to previous error