Skip to content

Commit 69ab0bc

Browse files
committed
Use 'error-pattern' in ui test
1 parent bdda98a commit 69ab0bc

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

src/test/ui/assume-type-intrinsics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
// error-pattern: any use of this value will cause an error
2+
13
#![feature(never_type)]
24
#![feature(const_maybe_uninit_assume_init)]
35

6+
#[allow(invalid_value)]
47
fn main() {
58
use std::mem::MaybeUninit;
69

710
const _BAD: () = unsafe {
811
MaybeUninit::<!>::uninit().assume_init();
9-
//~^ WARN: the type `!` does not permit being left uninitialized
1012
};
1113
}

src/test/ui/assume-type-intrinsics.stderr

+3-16
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,16 @@ LL | intrinsics::assert_inhabited::<T>();
66
| |
77
| attempted to instantiate uninhabited type `!`
88
| inside `MaybeUninit::<!>::assume_init` at $SRC_DIR/core/src/mem/maybe_uninit.rs:LL:COL
9-
| inside `_BAD` at $DIR/assume-type-intrinsics.rs:8:9
9+
| inside `_BAD` at $DIR/assume-type-intrinsics.rs:11:9
1010
|
11-
::: $DIR/assume-type-intrinsics.rs:7:5
11+
::: $DIR/assume-type-intrinsics.rs:10:5
1212
|
1313
LL | / const _BAD: () = unsafe {
1414
LL | | MaybeUninit::<!>::uninit().assume_init();
15-
LL | |
1615
LL | | };
1716
| |______-
1817
|
1918
= note: `#[deny(const_err)]` on by default
2019

21-
warning: the type `!` does not permit being left uninitialized
22-
--> $DIR/assume-type-intrinsics.rs:8:9
23-
|
24-
LL | MaybeUninit::<!>::uninit().assume_init();
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26-
| |
27-
| this code causes undefined behavior when executed
28-
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
29-
|
30-
= note: `#[warn(invalid_value)]` on by default
31-
= note: the `!` type has no valid value
32-
33-
error: aborting due to previous error; 1 warning emitted
20+
error: aborting due to previous error
3421

0 commit comments

Comments
 (0)