From 67b46141804132919a7976b3484cbcf6055e431e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Wed, 5 Apr 2023 00:00:00 +0000 Subject: [PATCH 1/2] Inline try_from and try_into To avoid link time dependency between core and compiler-builtins, when using opt-level that implicitly enables -Zshare-generics. While compiler-builtins should be compiled with -Zshare-generics disabled, the -Zbuild-std does not ensure this at the moment. --- library/core/src/convert/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 8a8d4caf96f33..5888e2960bb7e 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -764,6 +764,7 @@ where { type Error = U::Error; + #[inline] fn try_into(self) -> Result { U::try_from(self) } @@ -779,6 +780,7 @@ where { type Error = Infallible; + #[inline] fn try_from(value: U) -> Result { Ok(U::into(value)) } From 7ddc245b145bf8b1a1d6472ff7b43a2acd8f2ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Fri, 7 Apr 2023 00:00:00 +0000 Subject: [PATCH 2/2] ./x.py test --bless --- ...unchecked_shl_unsigned_smaller.Inline.diff | 123 +++++++++++------- ..._shl_unsigned_smaller.PreCodegen.after.mir | 116 ++++++++++------- ...s.unchecked_shr_signed_smaller.Inline.diff | 123 +++++++++++------- ...ed_shr_signed_smaller.PreCodegen.after.mir | 116 ++++++++++------- 4 files changed, 296 insertions(+), 182 deletions(-) diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff index bf05ed4171810..6184a0acd1879 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff @@ -14,36 +14,45 @@ + let mut _6: std::option::Option; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _7: std::result::Result; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 2 { -+ scope 3 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ debug self => _7; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _8: isize; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _9: u16; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ scope 4 { -+ debug x => _9; // in scope 4 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 3 (inlined >::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 4 (inlined convert::num:: for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } -+ scope 5 { -+ scope 6 { -+ debug x => const TryFromIntError(()); // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 5 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 6 { ++ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 7 { ++ scope 8 { ++ debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + } -+ scope 7 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ debug self => _6; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _10: &std::option::Option; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 8 { -+ debug val => _5; // in scope 8 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 10 { ++ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } -+ scope 9 { -+ scope 11 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 12 { -+ scope 13 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ scope 11 { ++ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 14 { ++ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } -+ scope 10 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _10; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } @@ -55,58 +64,78 @@ StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 _4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 - _0 = core::num::::unchecked_shl(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23 +- // mir::Constant +- // + span: $DIR/unchecked_shifts.rs:11:7: 11:20 +- // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::::unchecked_shl}, val: Value() } + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ _7 = >::try_into(_4) -> bb1; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - // mir::Constant -- // + span: $DIR/unchecked_shifts.rs:11:7: 11:20 -- // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::::unchecked_shl}, val: Value() } -+ // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ // + literal: Const { ty: fn(u32) -> Result>::Error> {>::try_into}, val: Value() } ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { -+ StorageLive(_9); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ _8 = discriminant(_7); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _8) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb2: { -+ StorageDead(_9); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ _11 = discriminant(_6); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _11) -> [1: bb7, otherwise: bb5]; // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + -+ bb3: { ++ bb2: { + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + } + ++ bb3: { ++ _7 = Result::::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: TryFromIntError, val: Value() } ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ + bb4: { -+ _6 = Option::::None; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb2; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb5: { -+ unreachable; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { -+ _9 = move ((_7 as Ok).0: u16); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ _6 = Option::::Some(move _9); // scope 4 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb2; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { -+ _5 = move ((_6 as Some).0: u16); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb8: { ++ _12 = move ((_7 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb9: { ++ _5 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ _0 = unchecked_shl::(_3, move _5) -> [return: bb3, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _0 = unchecked_shl::(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::}, val: Value() } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir index 7f6e974f66b1d..726b6bbf93b5c 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir @@ -11,36 +11,45 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { let mut _4: std::option::Option; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL let mut _5: std::result::Result; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL scope 2 { - scope 3 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - debug self => _5; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _6: isize; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - let _7: u16; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - scope 4 { - debug x => _7; // in scope 4 at $SRC_DIR/core/src/result.rs:LL:COL + scope 3 (inlined >::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 4 (inlined convert::num:: for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } - scope 5 { - scope 6 { - debug x => const TryFromIntError(()); // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 5 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _10: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + scope 6 { + debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 7 { + scope 8 { + debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL } } } - scope 7 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - debug self => _4; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _8: &std::option::Option; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _9: isize; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - scope 8 { - debug val => _3; // in scope 8 at $SRC_DIR/core/src/option.rs:LL:COL + scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _11: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL } - scope 9 { - scope 11 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL - scope 12 { - scope 13 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 11 { + scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 14 { + scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL } } } } - scope 10 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _8; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL } } } @@ -50,51 +59,70 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _5 = >::try_into(_2) -> bb1; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - // + literal: Const { ty: fn(u32) -> Result>::Error> {>::try_into}, val: Value() } + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _6 = discriminant(_5); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _6) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb2: { - StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageLive(_8); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _9 = discriminant(_4); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _9) -> [1: bb7, otherwise: bb5]; // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } bb3: { - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + _5 = Result::::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value() } + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb4: { - _4 = Option::::None; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb2; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = _2 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = Result::::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb5: { - unreachable; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - _7 = move ((_5 as Ok).0: u16); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - _4 = Option::::Some(move _7); // scope 4 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb2; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb7: { - _3 = move ((_4 as Some).0: u16); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_8); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { + _10 = move ((_5 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb9: { + _3 = move ((_4 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _0 = unchecked_shl::(_1, move _3) -> [return: bb3, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _0 = unchecked_shl::(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::}, val: Value() } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff index 5c4fb5ba8ba24..35d5b6e72f28f 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff @@ -14,36 +14,45 @@ + let mut _6: std::option::Option; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _7: std::result::Result; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + scope 2 { -+ scope 3 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ debug self => _7; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _8: isize; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _9: i16; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ scope 4 { -+ debug x => _9; // in scope 4 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 3 (inlined >::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 4 (inlined convert::num:: for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } -+ scope 5 { -+ scope 6 { -+ debug x => const TryFromIntError(()); // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 5 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 6 { ++ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 7 { ++ scope 8 { ++ debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + } -+ scope 7 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ debug self => _6; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _10: &std::option::Option; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 8 { -+ debug val => _5; // in scope 8 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 10 { ++ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } -+ scope 9 { -+ scope 11 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 12 { -+ scope 13 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL ++ scope 11 { ++ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 14 { ++ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } -+ scope 10 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _10; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL ++ scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } @@ -55,58 +64,78 @@ StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 _4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 - _0 = core::num::::unchecked_shr(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23 +- // mir::Constant +- // + span: $DIR/unchecked_shifts.rs:17:7: 17:20 +- // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::::unchecked_shr}, val: Value() } + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ _7 = >::try_into(_4) -> bb1; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - // mir::Constant -- // + span: $DIR/unchecked_shifts.rs:17:7: 17:20 -- // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::::unchecked_shr}, val: Value() } -+ // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ // + literal: Const { ty: fn(u32) -> Result>::Error> {>::try_into}, val: Value() } ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { -+ StorageLive(_9); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ _8 = discriminant(_7); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _8) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb2: { -+ StorageDead(_9); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ _11 = discriminant(_6); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _11) -> [1: bb7, otherwise: bb5]; // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + -+ bb3: { ++ bb2: { + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + } + ++ bb3: { ++ _7 = Result::::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: TryFromIntError, val: Value() } ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ + bb4: { -+ _6 = Option::::None; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb2; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb5: { -+ unreachable; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { -+ _9 = move ((_7 as Ok).0: i16); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL -+ _6 = Option::::Some(move _9); // scope 4 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb2; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { -+ _5 = move ((_6 as Some).0: i16); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb8: { ++ _12 = move ((_7 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb9: { ++ _5 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ _0 = unchecked_shr::(_3, move _5) -> [return: bb3, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _0 = unchecked_shr::(_3, move _5) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::}, val: Value() } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir index 698a3c6565500..b006085b54c58 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir @@ -11,36 +11,45 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { let mut _4: std::option::Option; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL let mut _5: std::result::Result; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL scope 2 { - scope 3 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - debug self => _5; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _6: isize; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - let _7: i16; // in scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - scope 4 { - debug x => _7; // in scope 4 at $SRC_DIR/core/src/result.rs:LL:COL + scope 3 (inlined >::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 4 (inlined convert::num:: for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } - scope 5 { - scope 6 { - debug x => const TryFromIntError(()); // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 5 (inlined Result::::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _10: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + scope 6 { + debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 7 { + scope 8 { + debug x => const TryFromIntError(()); // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL } } } - scope 7 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - debug self => _4; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _8: &std::option::Option; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _9: isize; // in scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - scope 8 { - debug val => _3; // in scope 8 at $SRC_DIR/core/src/option.rs:LL:COL + scope 9 (inlined #[track_caller] Option::::unwrap_unchecked) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _11: &std::option::Option; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL } - scope 9 { - scope 11 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL - scope 12 { - scope 13 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 11 { + scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 14 { + scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL } } } } - scope 10 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _8; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + scope 12 (inlined Option::::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL } } } @@ -50,51 +59,70 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - _5 = >::try_into(_2) -> bb1; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL - // + literal: Const { ty: fn(u32) -> Result>::Error> {>::try_into}, val: Value() } + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - _6 = discriminant(_5); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _6) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb2: { - StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageLive(_8); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - _9 = discriminant(_4); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _9) -> [1: bb7, otherwise: bb5]; // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } bb3: { - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 + _5 = Result::::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value() } + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb4: { - _4 = Option::::None; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb2; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = _2 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = Result::::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb5: { - unreachable; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - _7 = move ((_5 as Ok).0: i16); // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL - _4 = Option::::Some(move _7); // scope 4 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb2; // scope 3 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb7: { - _3 = move ((_4 as Some).0: i16); // scope 7 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_8); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { + _10 = move ((_5 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb9: { + _3 = move ((_4 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - _0 = unchecked_shr::(_1, move _3) -> [return: bb3, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _0 = unchecked_shr::(_1, move _3) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::}, val: Value() }