mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
feat: Tag macro calls as unsafe if they expand to unsafe expressions
This commit is contained in:
parent
5a87f09a71
commit
68de7b30e0
25 changed files with 208 additions and 68 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue