Open
Description
Minimal reproduction:
macro_rules! x86_feature_detect {
($name:ident -> $feature:literal) => {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
thread_local! {
pub static $name: core::cell::LazyCell<bool> = core::cell::LazyCell::new(|| is_x86_feature_detected!($feature));
}
};
}
x86_feature_detect!(SUPPORTS_AVX -> "avx2");
"avx2" is a feature for x86 documented at https://doc.rust-lang.org/std/macro.is_x86_feature_detected.html
The error:
Compiling playground v0.0.1 (/playground)
error: unknown x86 target feature: avx2
--> src/lib.rs:11:1
|
11 | x86_feature_detect!(SUPPORTS_AVX -> "avx2");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `is_x86_feature_detected` which comes from the expansion of the macro `x86_feature_detect` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `playground` (lib) due to 1 previous error
This error is unclear -- and hard to reason about/diagnose since it comes from within a macro.
Based on the docs at https://doc.rust-lang.org/std/macro.is_x86_feature_detected.html,
I changed the type from literal
to tt
and it compiled as expected ("fixed" playground permalink).
This behavior appears consistent on stable and nightly.
Metadata
Metadata
Assignees
Labels
Area: Enabling/disabling target features like AVX, Neon, etc.Category: This is a bug.Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.