Skip to content

Commit 9031c86

Browse files
committed
test: add test case for highlight unsafe operations
1 parent f6f92a2 commit 9031c86

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/tools/rust-analyzer/crates/ide/src/highlight_related.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,34 @@ mod tests {
811811
assert_eq!(expected, actual);
812812
}
813813

814+
#[test]
815+
fn test_hl_unsafe_block() {
816+
check(
817+
r#"
818+
fn foo() {
819+
unsafe fn this_is_unsafe_function() {
820+
}
821+
822+
823+
unsa$0fe {
824+
//^^^^^^
825+
let raw_ptr = &42 as *const i32;
826+
let val = *raw_ptr;
827+
//^^^^^^^^
828+
829+
let mut_ptr = &mut 5 as *mut i32;
830+
*mut_ptr = 10;
831+
//^^^^^^^^
832+
833+
this_is_unsafe_function();
834+
//^^^^^^^^^^^^^^^^^^^^^^^^^
835+
}
836+
837+
}
838+
"#,
839+
);
840+
}
841+
814842
#[test]
815843
fn test_hl_tuple_fields() {
816844
check(

0 commit comments

Comments
 (0)