rust/tests/ui/precondition-checks/out-of-bounds-get-unchecked.rs

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

12 lines
245 B
Rust
Raw Normal View History

2024-02-07 09:30:11 -06:00
//@ run-fail
//@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes
//@ error-pattern: slice::get_unchecked requires
2024-02-07 09:30:11 -06:00
//@ ignore-debug
fn main() {
unsafe {
let sli: &[u8] = &[0];
sli.get_unchecked(1);
}
}