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:
Chayim Refael Friedman 2024-08-29 22:58:26 +03:00
parent 3d21d5e614
commit 91f2016ee1
4 changed files with 51 additions and 6 deletions

View file

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