Skip to content

is_x86_feature_detected! does not work with $:literal argument #72726

@dtolnay

Description

@dtolnay
macro_rules! my_is_x86_feature_detected {
    ($feat:literal) => {  // changing to $feat:tt makes it work
        is_x86_feature_detected!($feat)
    };
}

fn main() {
    let _ = is_x86_feature_detected!("mmx");  // works
    let _ = my_is_x86_feature_detected!("mmx");  // does not work
}
error: unknown x86 target feature: mmx
 --> src/main.rs:8:13
  |
8 |     let _ = my_is_x86_feature_detected!("mmx");
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

The std::is_x86_feature_detected! macro appears to work when called with a string literal argument, and works when called with a $:tt argument, but does not work with a $:literal argument. I believe that it should work all three ways.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-SIMDArea: SIMD (Single Instruction Multiple Data)C-bugCategory: This is a bug.O-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)O-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions