rust/tests/ui/static/reference-of-mut-static-unsafe-fn.rs
2024-01-06 06:31:36 +03:00

24 lines
540 B
Rust

// compile-flags: --edition 2024 -Z unstable-options
fn main() {}
unsafe fn _foo() {
static mut X: i32 = 1;
static mut Y: i32 = 1;
let _y = &X;
//~^ ERROR reference of mutable static is disallowed
let ref _a = X;
//~^ ERROR reference of mutable static is disallowed
let (_b, _c) = (&X, &Y);
//~^ ERROR reference of mutable static is disallowed
//~^^ ERROR reference of mutable static is disallowed
foo(&X);
//~^ ERROR reference of mutable static is disallowed
}
fn foo<'a>(_x: &'a i32) {}