Closed
Description
fn foo(x: Result<u32,!>) -> u32 { x.unwrap() }
compiles in release to
define i32 @foo(i64) unnamed_addr #1 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality {
start:
%1 = and i64 %0, 4294967295
%cond.i = icmp eq i64 %1, 0
br i1 %cond.i, label %"_ZN47_$LT$core..result..Result$LT$T$C$$u20$E$GT$$GT$6unwrap17h6dfb0b0940cfa89bE.exit", label %bb3.i
bb3.i: ; preds = %start
; call core::result::unwrap_failed
tail call fastcc void @_ZN4core6result13unwrap_failed17h70f49da6467af679E()
unreachable
"_ZN47_$LT$core..result..Result$LT$T$C$$u20$E$GT$$GT$6unwrap17h6dfb0b0940cfa89bE.exit": ; preds = %start
%self.sroa.4.0.extract.shift.i = lshr i64 %0, 32
%self.sroa.4.0.extract.trunc.i = trunc i64 %self.sroa.4.0.extract.shift.i to i32
ret i32 %self.sroa.4.0.extract.trunc.i
}
given that the Err
variant is !
, the type system information should be sufficient for it to become just
ret i32 %0
Playground repro: https://play.rust-lang.org/?gist=af0170fb612114692ff35dab58c81615&version=nightly&mode=release