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

8 lines
219 B
Rust

static ARRAY: [u8; 2] = [0, 1];
fn main() {
let ptr_to_first = &ARRAY[0] as *const u8;
// Illegally use this to access the 2nd element.
let _val = unsafe { *ptr_to_first.add(1) }; //~ ERROR: borrow stack
}