1 // compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts
3 // Tests various cases that the `early_otherwise_branch` opt should *not* optimize
11 // EMIT_MIR early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff
12 fn no_downcast(e: &E) -> u32 {
13 if let E::Some(E::Some(_)) = e { 1 } else { 2 }
16 // SAFETY: if `a` is `Some`, `b` must point to a valid, initialized value
17 // EMIT_MIR early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff
18 unsafe fn no_deref_ptr(a: Option<i32>, b: *const Option<i32>) -> i32 {
20 // `*b` being correct depends on `a == Some(_)`
30 no_downcast(&E::Empty);
31 unsafe { no_deref_ptr(None, std::ptr::null()) };