about summary refs log tree commit diff
path: root/tests/codegen-llvm/issues/num-is-digit-to-digit-59352.rs
blob: 1d23eb2cdf9e4f73189be0f33a0bd5a18830b4b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Tests that there's no panic on unwrapping `to_digit` call after checking
// with `is_digit`.

//@ compile-flags: -Copt-level=3

#![crate_type = "lib"]

// CHECK-LABEL: @num_to_digit_slow
#[no_mangle]
pub fn num_to_digit_slow(num: char) -> u32 {
    // CHECK-NOT: br
    // CHECK-NOT: panic
    if num.is_digit(8) { num.to_digit(8).unwrap() } else { 0 }
}