test: add test case for highlight unsafe operations

This commit is contained in:
gohome001 2025-04-25 16:01:20 +08:00
parent f6f92a22ba
commit 9031c86009

View file

@ -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(