Skip to content

rust-analyzer doesn't recognize #[target_feature(enable = "a", enable = "b")] and considers no features enabled #21024

@Shnatsel

Description

@Shnatsel

rust-analyzer version: 0.3.2675-standalone

rustc version: rustc 1.91.1 (ed61e7d7e 2025-11-07)

editor or extension: VSCodium, extension version 0.3.2675

repository link (if public, optional): https://github.com/Shnatsel/moxcms/blob/dba2d902e63d6abc03ab423803ff19f6914c391a/src/conversions/avx/rgb_xyz.rs#L61

code snippet to reproduce:

#[target_feature(enable = "avx2", enable = "fma")]
fn do_avx_stuff() {
    use std::arch::x86_64::_mm256_setr_ps;
    let m0 = _mm256_setr_ps(
        1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
    );
}

rustc accepts this snippet but RA reports a hard error:

call to unsafe function is unsafe and requires an unsafe function or block

If I rewrite the target_feature declaration as #[target_feature(enable = "avx2,fma")] then it works. #[target_feature(enable = "avx2")] also works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions