about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/ide
diff options
context:
space:
mode:
authorChayim Refael Friedman <chayimfr@gmail.com>2025-01-26 23:31:58 +0200
committerChayim Refael Friedman <chayimfr@gmail.com>2025-01-26 23:31:58 +0200
commit5de2cd4b1360a72e57bf8eeb2d5770e2e8e263d0 (patch)
treefb5c170229dd07a8e192a187a8159b2c02df62f3 /src/tools/rust-analyzer/crates/ide
parenta7cbe4bedd2a8a75ab1690d9429477b7b80ea834 (diff)
downloadrust-5de2cd4b1360a72e57bf8eeb2d5770e2e8e263d0.tar.gz
rust-5de2cd4b1360a72e57bf8eeb2d5770e2e8e263d0.zip
Support RFC 2396
AKA. target_feature 1.1, or non unsafe target_feature.
Diffstat (limited to 'src/tools/rust-analyzer/crates/ide')
-rw-r--r--src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs
index 22a2fe4e9eb..a0c8b285683 100644
--- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/highlight.rs
@@ -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) {