rust/tests/fail/stacked_borrows/static_memory_modification.rs
2022-07-11 11:48:56 +00:00

9 lines
196 B
Rust

static X: usize = 5;
#[allow(mutable_transmutes)]
fn main() {
let _x = unsafe {
std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR: writing to alloc1 which is read-only
};
}