mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
21 lines
564 B
Rust
21 lines
564 B
Rust
//@ run-fail
|
|
//@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes
|
|
//@ error-pattern: unsafe precondition(s) violated: slice::get_unchecked requires
|
|
//@ revisions: usize range range_to range_from backwards_range
|
|
|
|
fn main() {
|
|
unsafe {
|
|
let s = &[0];
|
|
#[cfg(usize)]
|
|
s.get_unchecked(1);
|
|
#[cfg(range)]
|
|
s.get_unchecked(1..2);
|
|
#[cfg(range_to)]
|
|
s.get_unchecked(..2);
|
|
#[cfg(range_from)]
|
|
s.get_unchecked(2..);
|
|
#[cfg(backwards_range)]
|
|
s.get_unchecked(1..0);
|
|
}
|
|
}
|