Closed
Description
rust-analyzer version: 0.4.2302-standalone
rustc version: rustc 1.86.0-nightly (ef148cd7e 2025-02-12)
code snippet to reproduce:
#![feature(target_feature_11)]
#[target_feature(enable = "avx")]
fn f() {}
#[target_feature(enable = "avx2")]
fn g() {
f();
// it's safe, because enabling `avx2` enables `avx` implicitly, but ra reports that it's unsafe
// https://github.com/rust-lang/reference/pull/1720 describe it, and nightly rustc agrees with it
}
This should be caused by
rust-analyzer/crates/hir-ty/src/utils.rs
Lines 316 to 320 in 51389bd
It should calculate the set of all explicit-enabled and implicit-enabled target features of caller and calee, and then check if's a subset.
The "target feature to implicit-enabled target features" relationship is recorded in https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/target_features.rs. (How to get it in ra?)