Add const-eval test for #[target_feature(enable = ...)] function calls

This commit is contained in:
Eduardo Sánchez Muñoz 2023-07-16 13:20:06 +02:00
parent b5fde0dae0
commit 3e8ce42d42
2 changed files with 26 additions and 0 deletions

View 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() {}

View File

@ -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`.