rust/tests/ui/consts/write_to_static_via_mut_ref.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

6 lines
209 B
Rust
Raw Permalink Normal View History

static OH_NO: &mut i32 = &mut 42; //~ ERROR mutable references are not allowed
2019-11-28 10:38:07 -06:00
fn main() {
2020-06-08 15:16:23 -05:00
assert_eq!(*OH_NO, 42);
*OH_NO = 43; //~ ERROR cannot assign to `*OH_NO`, as `OH_NO` is an immutable static
2019-11-28 10:38:07 -06:00
}