about summary refs log tree commit diff
path: root/tests/mir-opt/instsimplify/ub_check.rs
blob: b513f60dc7b94ff2333c36a13dadfe9caddb0fd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//@ test-mir-pass: InstSimplify-after-simplifycfg
//@ compile-flags: -Cdebug-assertions=no -Zinline-mir

// EMIT_MIR ub_check.unwrap_unchecked.InstSimplify-after-simplifycfg.diff
pub fn unwrap_unchecked(x: Option<i32>) -> i32 {
    // CHECK-LABEL: fn unwrap_unchecked(
    // CHECK-NOT: UbChecks()
    // CHECK: [[assume:_.*]] = const false;
    // CHECK-NEXT: assume(copy [[assume]]);
    // CHECK-NEXT: unreachable_unchecked::precondition_check
    unsafe { x.unwrap_unchecked() }
}

fn main() {
    unwrap_unchecked(None);
}