about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorgohome001 <3156514693@qq.com>2025-04-25 16:01:20 +0800
committergohome001 <3156514693@qq.com>2025-04-25 16:06:48 +0800
commit9031c86009c4d09cc315670bb3e03b70ef2d5edf (patch)
treed426b049fd277737cc4410265d6ec5c4d6cbf9e1 /src/tools
parentf6f92a22ba451e42313c90fb8214f5d26ec71dfd (diff)
downloadrust-9031c86009c4d09cc315670bb3e03b70ef2d5edf.tar.gz
rust-9031c86009c4d09cc315670bb3e03b70ef2d5edf.zip
test: add test case for highlight unsafe operations
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/rust-analyzer/crates/ide/src/highlight_related.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs b/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs
index 750ad230262..2943d60682a 100644
--- a/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs
@@ -812,6 +812,34 @@ mod tests {
     }
 
     #[test]
+    fn test_hl_unsafe_block() {
+        check(
+            r#"
+fn foo() {
+    unsafe fn this_is_unsafe_function() {
+    }
+
+    
+    unsa$0fe {
+  //^^^^^^
+        let raw_ptr = &42 as *const i32;
+        let val = *raw_ptr;
+                //^^^^^^^^
+        
+        let mut_ptr = &mut 5 as *mut i32;
+        *mut_ptr = 10;
+      //^^^^^^^^
+        
+        this_is_unsafe_function();
+      //^^^^^^^^^^^^^^^^^^^^^^^^^
+    }
+    
+}
+"#,
+        );
+    }
+
+    #[test]
     fn test_hl_tuple_fields() {
         check(
             r#"