Moved failing test to src/test/ui/
Still have not figured out how to make it work
This commit is contained in:
parent
94762417e8
commit
4255a5afd5
3 changed files with 51 additions and 10 deletions
|
@ -131,18 +131,9 @@ fn test_discriminant_send_sync() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(bootstrap))]
|
||||
fn assume_init_good() {
|
||||
const TRUE: bool = unsafe { MaybeUninit::<bool>::new(true).assume_init() };
|
||||
|
||||
assert!(TRUE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assume_init_bad() {
|
||||
const _BAD: () = unsafe {
|
||||
MaybeUninit::<!>::uninit().assume_init();
|
||||
//~^ ERROR the type `!` does not permit being left uninitialized
|
||||
//~| ERROR this code causes undefined behavior when executed
|
||||
//~| ERROR help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
||||
};
|
||||
}
|
||||
|
|
13
src/test/ui/assume-type-intrinsics.rs
Normal file
13
src/test/ui/assume-type-intrinsics.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
#![feature(never_type)]
|
||||
#![feature(const_maybe_uninit_assume_init)]
|
||||
|
||||
fn main() {
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
const _BAD: () = unsafe {
|
||||
MaybeUninit::<!>::uninit().assume_init();
|
||||
//~^ ERROR: the type `!` does not permit being left uninitialized
|
||||
//~| this code causes undefined behavior when executed
|
||||
//~| WARN: the type `!` does not permit being left uninitialized
|
||||
};
|
||||
}
|
37
src/test/ui/assume-type-intrinsics.stderr
Normal file
37
src/test/ui/assume-type-intrinsics.stderr
Normal file
|
@ -0,0 +1,37 @@
|
|||
error: any use of this value will cause an error
|
||||
--> $SRC_DIR/core/src/mem/maybe_uninit.rs:LL:COL
|
||||
|
|
||||
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
|
||||
|
|
||||
::: $DIR/assume-type-intrinsics.rs:7:5
|
||||
|
|
||||
LL | / const _BAD: () = unsafe {
|
||||
LL | | MaybeUninit::<!>::uninit().assume_init();
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue