rust/tests/ui/lint/unconditional_panic_promoted.rs
fudancoder e97be25aa9 Fix some typos
Signed-off-by: fudancoder <fudancoder@icloud.com.>
2024-12-24 11:35:38 +08:00

9 lines
274 B
Rust

//@ build-fail
fn main() {
// MIR encodes this as a reborrow from a promoted constant.
// But the array length can still be gotten from the type.
let slice = &[0, 1];
let _ = slice[2]; //~ ERROR: this operation will panic at runtime [unconditional_panic]
}