Support RFC 2396

AKA. target_feature 1.1, or non unsafe target_feature.
This commit is contained in:
Chayim Refael Friedman 2025-01-26 23:31:58 +02:00
parent 2df4ecfc74
commit 791b1ebfd4
14 changed files with 132 additions and 24 deletions

View file

@ -427,7 +427,11 @@ pub(super) fn highlight_def(
}
}
if func.is_unsafe_to_call(db) {
// FIXME: Passing `None` here means not-unsafe functions with `#[target_feature]` will be
// highlighted as unsafe, even when the current target features set is a superset (RFC 2396).
// We probably should consider checking the current function, but I found no easy way to do
// that (also I'm worried about perf). There's also an instance below.
if func.is_unsafe_to_call(db, None) {
h |= HlMod::Unsafe;
}
if func.is_async(db) {
@ -589,7 +593,7 @@ fn highlight_method_call(
let mut h = SymbolKind::Method.into();
if func.is_unsafe_to_call(sema.db) || sema.is_unsafe_method_call(method_call) {
if func.is_unsafe_to_call(sema.db, None) || sema.is_unsafe_method_call(method_call) {
h |= HlMod::Unsafe;
}
if func.is_async(sema.db) {