Add const-eval test for #[target_feature(enable = ...)]
function calls
This commit is contained in:
parent
b5fde0dae0
commit
3e8ce42d42
17
tests/ui/consts/const-eval/const_fn_target_feature.rs
Normal file
17
tests/ui/consts/const-eval/const_fn_target_feature.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// only-x86_64
|
||||
// compile-flags:-C target-feature=+ssse3
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// ok (ssse3 enabled at compile time)
|
||||
const A: () = unsafe { ssse3_fn() };
|
||||
|
||||
// error (avx2 not enabled at compile time)
|
||||
const B: () = unsafe { avx2_fn() };
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
#[target_feature(enable = "ssse3")]
|
||||
const unsafe fn ssse3_fn() {}
|
||||
|
||||
#[target_feature(enable = "avx2")]
|
||||
const unsafe fn avx2_fn() {}
|
@ -0,0 +1,9 @@
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_fn_target_feature.rs:10:24
|
||||
|
|
||||
LL | const B: () = unsafe { avx2_fn() };
|
||||
| ^^^^^^^^^ calling a function that requires unavailable target features: avx2
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
Loading…
x
Reference in New Issue
Block a user