about summary refs log tree commit diff
path: root/tests/codegen/issues/issue-111508-vec-tryinto-array.rs
blob: 2e7244e9713074d8f62e911363df63c36cd07907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//@ compile-flags: -O
// This regress since Rust version 1.72.
//@ min-llvm-version: 18.1.4

#![crate_type = "lib"]

use std::convert::TryInto;

const N: usize = 24;

#[no_mangle]
// CHECK-LABEL: @example
// CHECK-NOT: unwrap_failed
pub fn example(a: Vec<u8>) -> u8 {
    if a.len() != 32 {
        return 0;
    }

    let a: [u8; 32] = a.try_into().unwrap();

    a[15] + a[N]
}