feat: Tag macro calls as unsafe if they expand to unsafe expressions

This commit is contained in:
Lukas Wirth 2022-03-20 19:07:44 +01:00
parent 5a87f09a71
commit 68de7b30e0
25 changed files with 208 additions and 68 deletions

View file

@ -483,6 +483,16 @@ fn main() {
fn test_unsafe_highlighting() {
check_highlighting(
r#"
macro_rules! id {
($($tt:tt)*) => {
$($tt)*
};
}
macro_rules! unsafe_deref {
() => {
*(&() as *const ())
};
}
static mut MUT_GLOBAL: Struct = Struct { field: 0 };
static GLOBAL: Struct = Struct { field: 0 };
unsafe fn unsafe_fn() {}
@ -519,7 +529,15 @@ impl DoTheAutoref for u16 {
fn main() {
let x = &5 as *const _ as *const usize;
let u = Union { b: 0 };
id! {
unsafe { unsafe_deref!() }
};
unsafe {
unsafe_deref!();
id! { unsafe_deref!() };
// unsafe fn and method calls
unsafe_fn();
let b = u.b;