From 9031c86009c4d09cc315670bb3e03b70ef2d5edf Mon Sep 17 00:00:00 2001 From: gohome001 <3156514693@qq.com> Date: Fri, 25 Apr 2025 16:01:20 +0800 Subject: [PATCH] test: add test case for highlight unsafe operations --- .../crates/ide/src/highlight_related.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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 750ad2302629..2943d60682ad 100644 --- a/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs +++ b/src/tools/rust-analyzer/crates/ide/src/highlight_related.rs @@ -811,6 +811,34 @@ mod tests { assert_eq!(expected, actual); } + #[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(