Add a fail test
This commit is contained in:
parent
03ac54aed6
commit
75d8199ab1
2 changed files with 36 additions and 0 deletions
20
src/test/ui/consts/const-eval/const_eval-simd_fail.rs
Normal file
20
src/test/ui/consts/const-eval/const_eval-simd_fail.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(repr_simd)]
|
||||
#![feature(platform_intrinsics)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
#[repr(simd)] struct i8x1(i8);
|
||||
|
||||
extern "platform-intrinsic" {
|
||||
fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
|
||||
}
|
||||
|
||||
const fn foo(x: i8x1) -> i8 {
|
||||
// 42 is a i16 that does not fit in a i8
|
||||
unsafe { simd_insert(x, 0_u32, 42_i16) }.0 //~ ERROR
|
||||
}
|
||||
|
||||
fn main() {
|
||||
const V: i8x1 = i8x1(13);
|
||||
const X: i8 = foo(V);
|
||||
}
|
16
src/test/ui/consts/const-eval/const_eval-simd_fail.stderr
Normal file
16
src/test/ui/consts/const-eval/const_eval-simd_fail.stderr
Normal file
|
@ -0,0 +1,16 @@
|
|||
error: any use of this value will cause an error
|
||||
--> $DIR/const_eval-simd_fail.rs:14:14
|
||||
|
|
||||
LL | unsafe { simd_insert(x, 0_u32, 42_i16) }.0
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| Inserting `i16` with size `2` to a vector element place of size `1`
|
||||
| inside call to `foo` at $DIR/const_eval-simd_fail.rs:19:19
|
||||
...
|
||||
LL | const X: i8 = foo(V);
|
||||
| ---------------------
|
||||
|
|
||||
= note: `#[deny(const_err)]` on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in a new issue