mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Do not report missing unsafe on addr_of[_mut]!(EXTERN_OR_MUT_STATIC)
The compiler no longer does as well; see https://github.com/rust-lang/rust/pull/125834.
This commit is contained in:
parent
3d21d5e614
commit
91f2016ee1
4 changed files with 51 additions and 6 deletions
|
@ -188,6 +188,31 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_unsafe_diagnostic_with_addr_of_static() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: copy, addr_of
|
||||
|
||||
use core::ptr::{addr_of, addr_of_mut};
|
||||
|
||||
extern "C" {
|
||||
static EXTERN: i32;
|
||||
static mut EXTERN_MUT: i32;
|
||||
}
|
||||
static mut STATIC_MUT: i32 = 0;
|
||||
|
||||
fn main() {
|
||||
let _x = addr_of!(EXTERN);
|
||||
let _x = addr_of!(EXTERN_MUT);
|
||||
let _x = addr_of!(STATIC_MUT);
|
||||
let _x = addr_of_mut!(EXTERN_MUT);
|
||||
let _x = addr_of_mut!(STATIC_MUT);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_missing_unsafe_diagnostic_with_safe_intrinsic() {
|
||||
check_diagnostics(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue