Files
rust/tests/ui/precondition-checks/slice-swap_unchecked.rs

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

15 lines
340 B
Rust
Raw Normal View History

2024-10-07 19:34:25 -04:00
//@ run-fail
//@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes
//@ error-pattern: index out of bounds: the len is 2 but the index is 2
//@ revisions: oob_a oob_b
fn main() {
let mut pair = [0u8; 2];
unsafe {
#[cfg(oob_a)]
pair.swap(0, 2);
#[cfg(oob_b)]
pair.swap(2, 0);
}
}