rust/tests/ui/consts/write_to_static_via_mut_ref.rs
2024-09-15 09:51:32 +02:00

6 lines
209 B
Rust

static OH_NO: &mut i32 = &mut 42; //~ ERROR mutable references are not allowed
fn main() {
assert_eq!(*OH_NO, 42);
*OH_NO = 43; //~ ERROR cannot assign to `*OH_NO`, as `OH_NO` is an immutable static
}