From 2229863deec4554dee581348c6b66b427da0a407 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 27 Oct 2022 16:12:15 +0000 Subject: [PATCH 1/3] Constify `assert_eq!` and `assert_ne!` We provide an inferior type of formatting for use when panicking in compile time, which should not come with additional costs as the additional argument should be inlined and optimized away when in runtime --- library/core/src/macros/mod.rs | 8 +++---- library/core/src/panicking.rs | 40 +++++++++++++++++++++++++++++-- tests/ui/consts/assertions.rs | 15 ++++++++++++ tests/ui/consts/assertions.stderr | 27 +++++++++++++++++++++ 4 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 tests/ui/consts/assertions.rs create mode 100644 tests/ui/consts/assertions.stderr diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 3b026bc0e0f38..da810a12e1dcf 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -42,7 +42,7 @@ macro_rules! assert_eq { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::None); + $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::None, $crate::concat!("assertion failed: `", $crate::stringify!($left), " == ", $crate::stringify!($right), "`")); } } } @@ -55,7 +55,7 @@ macro_rules! assert_eq { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::Some($crate::format_args!($($arg)+))); + $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::Some($crate::format_args!($($arg)+)), $crate::concat!("assertion failed: `", $crate::stringify!($left), " == ", $crate::stringify!($right), "`")); } } } @@ -92,7 +92,7 @@ macro_rules! assert_ne { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::None); + $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::None, $crate::concat!("assertion failed: `", $crate::stringify!($left), " != ", $crate::stringify!($right), "`")); } } } @@ -105,7 +105,7 @@ macro_rules! assert_ne { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::Some($crate::format_args!($($arg)+))); + $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::Some($crate::format_args!($($arg)+)), $crate::concat!("assertion failed: `", $crate::stringify!($left), " != ", $crate::stringify!($right), "`")); } } } diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 48e90e6d79400..0744d10bcf520 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -199,17 +199,53 @@ pub enum AssertKind { #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] #[doc(hidden)] -pub fn assert_failed( +#[rustc_const_unstable(feature = "const_assert_eq", issue = "none")] +pub const fn assert_failed( kind: AssertKind, left: &T, right: &U, args: Option>, + string_for_const_msg: &str, ) -> ! where T: fmt::Debug + ?Sized, U: fmt::Debug + ?Sized, { - assert_failed_inner(kind, &left, &right, args) + #[track_caller] + const fn assert_failed_const_impl( + _: AssertKind, + _: &T, + _: &U, + _: Option>, + msg: &str, + ) -> ! { + panic_str(msg) + } + + #[track_caller] + #[inline] + fn assert_failed_runtime_impl( + kind: AssertKind, + left: &T, + right: &U, + args: Option>, + _: &str, + ) -> ! + where + T: fmt::Debug + ?Sized, + U: fmt::Debug + ?Sized, + { + assert_failed_inner(kind, &left, &right, args) + } + + // SAFETY: we are panicking in both branches, so this is consistent. + unsafe { + crate::intrinsics::const_eval_select( + (kind, left, right, args, string_for_const_msg), + assert_failed_const_impl, + assert_failed_runtime_impl, + ) + } } /// Internal function for `assert_match!` diff --git a/tests/ui/consts/assertions.rs b/tests/ui/consts/assertions.rs new file mode 100644 index 0000000000000..75a05a4f54fd5 --- /dev/null +++ b/tests/ui/consts/assertions.rs @@ -0,0 +1,15 @@ +#![feature(const_assert_eq)] + +const _BAD1: () = { + assert_eq!(1, 2) +}; //~^ ERROR: evaluation of constant value failed + +const _BAD2: () = { + assert_ne!(1, 1) +}; //~^ ERROR: evaluation of constant value failed + +const _BAD3: () = { + assert!(false) +}; //~^ ERROR: evaluation of constant value failed + +fn main() {} diff --git a/tests/ui/consts/assertions.stderr b/tests/ui/consts/assertions.stderr new file mode 100644 index 0000000000000..2801d0547752b --- /dev/null +++ b/tests/ui/consts/assertions.stderr @@ -0,0 +1,27 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/assertions.rs:4:5 + | +LL | assert_eq!(1, 2) + | ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: `1 == 2`', $DIR/assertions.rs:4:5 + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0080]: evaluation of constant value failed + --> $DIR/assertions.rs:8:5 + | +LL | assert_ne!(1, 1) + | ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: `1 != 1`', $DIR/assertions.rs:8:5 + | + = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0080]: evaluation of constant value failed + --> $DIR/assertions.rs:12:5 + | +LL | assert!(false) + | ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/assertions.rs:12:5 + | + = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0080`. From 4b7dc2ce69cdb0184dd16621b50da969765625ae Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Thu, 27 Oct 2022 18:13:42 +0000 Subject: [PATCH 2/3] bless mir --- .../inline/inline_generator.main.Inline.diff | 108 ++++++----- .../mir-opt/issue_99325.main.built.after.mir | 170 ++++++++++-------- ...ue_59352.num_to_digit.PreCodegen.after.mir | 81 +++++---- ...asts.SimplifyCfg-elaborate-drops.after.mir | 22 ++- 4 files changed, 207 insertions(+), 174 deletions(-) diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.diff b/tests/mir-opt/inline/inline_generator.main.Inline.diff index f27b64c305457..aa9deb87d87b5 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.diff @@ -7,7 +7,7 @@ let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 let mut _3: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 let mut _4: [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:28: +1:31 -+ let mut _7: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ let mut _6: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 scope 1 { debug _r => _1; // in scope 1 at $DIR/inline_generator.rs:+1:9: +1:11 } @@ -17,19 +17,15 @@ + debug pointer => _3; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL + let mut _5: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL + scope 4 { -+ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL -+ debug pointer => _5; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ let mut _6: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ } + } + } -+ scope 6 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:33: 9:46 -+ debug a => _7; // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7 -+ let mut _8: i32; // in scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ let mut _9: u32; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _11: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _12: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ scope 5 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:33: 9:46 ++ debug a => _6; // in scope 5 at $DIR/inline_generator.rs:15:6: 15:7 ++ let mut _7: i32; // in scope 5 at $DIR/inline_generator.rs:15:17: 15:39 ++ let mut _8: u32; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _9: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _11: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 + } bb0: { @@ -48,36 +44,28 @@ + discriminant(_4) = 0; // scope 2 at $DIR/inline_generator.rs:15:5: 15:41 _3 = &mut _4; // scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 - _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 -- // mir::Constant ++ StorageLive(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ _5 = move _3; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked(move _5) -> [return: bb3, unwind: bb2]; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL + // mir::Constant - // + span: $DIR/inline_generator.rs:9:14: 9:22 -- // + user_ty: UserType(0) ++ // + span: $SRC_DIR/core/src/pin.rs:LL:COL + // + user_ty: UserType(0) - // + literal: Const { ty: fn(&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new}, val: Value() } -- } -- ++ // + literal: Const { ty: unsafe fn(&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked}, val: Value() } + } + - bb2: { -+ StorageLive(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL -+ _5 = move _3; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL -+ StorageLive(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ _6 = move _5; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ Deinit(_2); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ StorageDead(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ StorageDead(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 +- StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 - _1 = <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46 - // mir::Constant - // + span: $DIR/inline_generator.rs:9:33: 9:39 - // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Yield, <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Return> {<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume}, val: Value() } -+ StorageLive(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _7 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ _9 = discriminant((*_10)); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ switchInt(move _9) -> [0: bb3, 1: bb8, 3: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 - } - +- } +- - bb3: { + bb1: { -+ StorageDead(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ StorageDead(_6); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 StorageDead(_2); // scope 0 at $DIR/inline_generator.rs:+1:45: +1:46 StorageDead(_4); // scope 0 at $DIR/inline_generator.rs:+1:46: +1:47 _0 = const (); // scope 0 at $DIR/inline_generator.rs:+0:11: +2:2 @@ -91,46 +79,56 @@ + } + + bb3: { -+ StorageLive(_8); // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ switchInt(move _7) -> [0: bb5, otherwise: bb4]; // scope 6 at $DIR/inline_generator.rs:15:20: 15:21 ++ StorageDead(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 ++ StorageLive(_6); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ _6 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ _8 = discriminant((*_9)); // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ switchInt(move _8) -> [0: bb4, 1: bb9, 3: bb8, otherwise: bb10]; // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 + } + + bb4: { -+ _8 = const 7_i32; // scope 6 at $DIR/inline_generator.rs:15:24: 15:25 -+ goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 ++ StorageLive(_7); // scope 5 at $DIR/inline_generator.rs:15:17: 15:39 ++ switchInt(move _6) -> [0: bb6, otherwise: bb5]; // scope 5 at $DIR/inline_generator.rs:15:20: 15:21 + } + + bb5: { -+ _8 = const 13_i32; // scope 6 at $DIR/inline_generator.rs:15:35: 15:37 -+ goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 ++ _7 = const 7_i32; // scope 5 at $DIR/inline_generator.rs:15:24: 15:25 ++ goto -> bb7; // scope 5 at $DIR/inline_generator.rs:15:17: 15:39 + } + + bb6: { -+ Deinit(_1); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ discriminant(_1) = 0; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ _11 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ discriminant((*_11)) = 3; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:11: 15:39 ++ _7 = const 13_i32; // scope 5 at $DIR/inline_generator.rs:15:35: 15:37 ++ goto -> bb7; // scope 5 at $DIR/inline_generator.rs:15:17: 15:39 + } + + bb7: { -+ StorageLive(_8); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ StorageDead(_8); // scope 6 at $DIR/inline_generator.rs:15:38: 15:39 -+ Deinit(_1); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ ((_1 as Complete).0: bool) = move _7; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ discriminant(_1) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ _12 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ discriminant((*_12)) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:41: 15:41 ++ Deinit(_1); // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 ++ ((_1 as Yielded).0: i32) = move _7; // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 ++ discriminant(_1) = 0; // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 ++ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 ++ discriminant((*_10)) = 3; // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 ++ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:11: 15:39 + } + + bb8: { -+ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ StorageLive(_7); // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ StorageDead(_7); // scope 5 at $DIR/inline_generator.rs:15:38: 15:39 ++ Deinit(_1); // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 ++ ((_1 as Complete).0: bool) = move _6; // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 ++ discriminant(_1) = 1; // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 ++ _11 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 ++ discriminant((*_11)) = 1; // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 ++ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:41: 15:41 + } + + bb9: { -+ unreachable; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ assert(const false, "generator resumed after completion") -> [success: bb9, unwind: bb2]; // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ } ++ ++ bb10: { ++ unreachable; // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 } } diff --git a/tests/mir-opt/issue_99325.main.built.after.mir b/tests/mir-opt/issue_99325.main.built.after.mir index 3e035c18db862..aab53e26a0aa8 100644 --- a/tests/mir-opt/issue_99325.main.built.after.mir +++ b/tests/mir-opt/issue_99325.main.built.after.mir @@ -27,26 +27,30 @@ fn main() -> () { let mut _20: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _21: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _22: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _23: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _24: (&&[u8], &&[u8; 4]); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _25: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _26: &[u8]; // in scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 - let mut _27: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _28: &[u8; 4]; // in scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 - let _29: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _30: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _31: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _32: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _33: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _34: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _35: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _37: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _38: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _39: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _40: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _41: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _42: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _43: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _23: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _24: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _25: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _26: (&&[u8], &&[u8; 4]); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _27: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _28: &[u8]; // in scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 + let mut _29: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _30: &[u8; 4]; // in scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 + let _31: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _32: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _33: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _34: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _35: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _36: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _37: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _39: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _40: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _41: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _42: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _43: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _44: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _45: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _46: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _47: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug left_val => _8; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _9; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -56,11 +60,11 @@ fn main() -> () { } } scope 3 { - debug left_val => _29; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _30; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _36: core::panicking::AssertKind; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug left_val => _31; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _38: core::panicking::AssertKind; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug kind => _36; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug kind => _38; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } @@ -129,10 +133,17 @@ fn main() -> () { _20 = &(*_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_22); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _22 = Option::>::None; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _17, move _18, move _20, move _22) -> bb19; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_23); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_24); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _24 = const "assertion failed: `function_with_bytes::() == &[0x41, 0x41, 0x41, 0x41]`"; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } + // + literal: Const { ty: &str, val: Value(Slice(..)) } + _23 = &(*_24); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _17, move _18, move _20, move _22, move _23) -> bb19; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'a, 'b, 'c, 'd> fn(core::panicking::AssertKind, &'a &[u8], &'b &[u8; 4], Option>, &'d str) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } } bb4: { @@ -140,10 +151,12 @@ fn main() -> () { } bb5: { + StorageDead(_23); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_22); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_20); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_18); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_17); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_24); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_16); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -173,11 +186,11 @@ fn main() -> () { StorageDead(_4); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_1); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_23); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_25); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_26); // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 - _26 = function_with_bytes::<&*b"AAAA">() -> [return: bb10, unwind: bb19]; // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 + StorageLive(_26); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_28); // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 + _28 = function_with_bytes::<&*b"AAAA">() -> [return: bb10, unwind: bb19]; // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 // mir::Constant // + span: $DIR/issue_99325.rs:11:16: 11:68 // + user_ty: UserType(1) @@ -185,63 +198,70 @@ fn main() -> () { } bb10: { - _25 = &_26; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_28); // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 - _28 = const b"AAAA"; // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 + _27 = &_28; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_30); // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 + _30 = const b"AAAA"; // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 // mir::Constant // + span: $DIR/issue_99325.rs:11:72: 11:79 // + literal: Const { ty: &[u8; 4], val: Value(Scalar(alloc4)) } - _27 = &_28; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = (move _25, move _27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _29 = &_30; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _26 = (move _27, move _29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_25); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - FakeRead(ForMatchedPlace(None), _24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _29 = (_24.0: &&[u8]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_30); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _30 = (_24.1: &&[u8; 4]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_31); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + FakeRead(ForMatchedPlace(None), _26); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_31); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _31 = (_26.0: &&[u8]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_32); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _32 = (_26.1: &&[u8; 4]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_33); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _33 = &(*_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_34); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _34 = &(*_30); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _32 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _33, move _34) -> [return: bb11, unwind: bb19]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_35); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _35 = &(*_31); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _36 = &(*_32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _34 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _35, move _36) -> [return: bb11, unwind: bb19]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'a, 'b> fn(&'a &[u8], &'b &[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } } bb11: { + StorageDead(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_35); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _33 = Not(move _34); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_34); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_33); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _31 = Not(move _32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _31) -> [0: bb13, otherwise: bb12]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _33) -> [0: bb13, otherwise: bb12]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb12: { - StorageLive(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _36 = core::panicking::AssertKind::Eq; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - FakeRead(ForLet(None), _36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_38); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _38 = move _36; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_38); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _38 = core::panicking::AssertKind::Eq; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + FakeRead(ForLet(None), _38); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_39); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _40 = &(*_29); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _39 = &(*_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _40 = move _38; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_41); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _42 = &(*_30); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _42 = &(*_31); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _41 = &(*_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_43); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _43 = Option::>::None; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _37 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _38, move _39, move _41, move _43) -> bb19; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_44); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _44 = &(*_32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _43 = &(*_44); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_45); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _45 = Option::>::None; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_46); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_47); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _47 = const "assertion failed: `function_with_bytes::<{ &[0x41, 0x41, 0x41, 0x41] }>() == b\"AAAA\"`"; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: &str, val: Value(Slice(..)) } + _46 = &(*_47); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _39 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _40, move _41, move _43, move _45, move _46) -> bb19; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } + // + literal: Const { ty: for<'a, 'b, 'c, 'd> fn(core::panicking::AssertKind, &'a &[u8], &'b &[u8; 4], Option>, &'d str) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } } bb13: { @@ -249,14 +269,16 @@ fn main() -> () { } bb14: { + StorageDead(_46); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_45); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_43); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_41); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_39); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_38); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_47); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_44); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_39); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_38); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL unreachable; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } @@ -265,22 +287,22 @@ fn main() -> () { } bb16: { - _23 = const (); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _25 = const (); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL goto -> bb17; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb17: { - StorageDead(_31); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_30); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_33); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_32); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_31); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL goto -> bb18; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb18: { + StorageDead(_30); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_28); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_26); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_23); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_25); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _0 = const (); // scope 0 at $DIR/issue_99325.rs:+0:15: +3:2 return; // scope 0 at $DIR/issue_99325.rs:+3:2: +3:2 } diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index c17d221f86a84..247ad2100a5cf 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -3,51 +3,48 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; // in scope 0 at $DIR/issue_59352.rs:+0:21: +0:24 let mut _0: u32; // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38 - let mut _2: std::option::Option; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 - let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - let mut _9: isize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _2: bool; // in scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + let mut _3: std::option::Option; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + let mut _4: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 scope 1 (inlined char::methods::::is_digit) { // at $DIR/issue_59352.rs:14:12: 14:23 - debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _4: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let _5: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _6: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - scope 2 (inlined Option::::is_some) { // at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug self => _4; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - } + debug self => _7; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug radix => _4; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let mut _5: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let _6: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let mut _7: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL } - scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:42: 14:50 - debug self => _2; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _8: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - scope 4 { - debug val => _0; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL + scope 2 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:42: 14:50 + debug self => _3; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _8: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _9: !; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + scope 3 { + debug val => _0; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL } } bb0: { - StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - StorageLive(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageLive(_2); // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + _7 = _1; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:11 + StorageLive(_4); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 StorageLive(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageLive(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _6 = _1; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _5 = char::methods::::to_digit(move _6, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _6 = char::methods::::to_digit(move _7, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/char/methods.rs:LL:COL // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } } bb1: { - StorageLive(_2); // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 - _2 = char::methods::::to_digit(move _1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + _3 = char::methods::::to_digit(move _1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 // mir::Constant // + span: $DIR/issue_59352.rs:14:30: 14:38 // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } } bb2: { - _7 = discriminant(_2); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _7) -> [0: bb6, 1: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _8 = discriminant(_3); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _8) -> [0: bb7, 1: bb9, otherwise: bb8]; // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL } bb3: { @@ -56,22 +53,28 @@ fn num_to_digit(_1: char) -> u32 { } bb4: { + StorageDead(_2); // scope 0 at $DIR/issue_59352.rs:+2:62: +2:63 return; // scope 0 at $DIR/issue_59352.rs:+3:2: +3:2 } bb5: { - _4 = &_5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _9 = discriminant((*_4)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - switchInt(move _9) -> [1: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + _5 = &_6; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _2 = Option::::is_some(move _5) -> bb6; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/char/methods.rs:LL:COL + // + literal: Const { ty: for<'a> fn(&'a Option) -> bool {Option::::is_some}, val: Value() } } bb6: { - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - _8 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageDead(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageDead(_4); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 + switchInt(move _2) -> [0: bb3, otherwise: bb1]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + } + + bb7: { + StorageLive(_9); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + _9 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/option.rs:LL:COL // + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value() } @@ -80,13 +83,13 @@ fn num_to_digit(_1: char) -> u32 { // + literal: Const { ty: &str, val: Value(Slice(..)) } } - bb7: { - unreachable; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + bb8: { + unreachable; // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL } - bb8: { - _0 = move ((_2 as Some).0: u32); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_2); // scope 0 at $DIR/issue_59352.rs:+2:49: +2:50 + bb9: { + _0 = move ((_3 as Some).0: u32); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:49: +2:50 goto -> bb4; // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63 } } diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir index 19b726e748453..fa7edf948af68 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir @@ -30,6 +30,8 @@ fn array_casts() -> () { let mut _32: &usize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _33: &usize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _34: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _35: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _36: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug x => _1; // in scope 1 at $DIR/retag.rs:+1:9: +1:14 let _2: *mut usize; // in scope 1 at $DIR/retag.rs:+2:9: +2:10 @@ -45,7 +47,7 @@ fn array_casts() -> () { debug p => _9; // in scope 5 at $DIR/retag.rs:+6:9: +6:10 let _20: &usize; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _21: &usize; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _35: &usize; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _37: &usize; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 6 { } scope 7 { @@ -116,12 +118,12 @@ fn array_casts() -> () { _15 = (*_16); // scope 6 at $DIR/retag.rs:+7:25: +7:34 _14 = &_15; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _35 = const _; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _37 = const _; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &usize, val: Unevaluated(array_casts, [], Some(promoted[0])) } - Retag(_35); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = &(*_35); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + Retag(_37); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _18 = &(*_37); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL Deinit(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_13.0: &usize) = move _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_13.1: &usize) = move _18; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -167,10 +169,18 @@ fn array_casts() -> () { Deinit(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL discriminant(_34) = 0; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL Retag(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _28 = core::panicking::assert_failed::(move _29, move _30, move _32, move _34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_35); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_36); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _36 = const "assertion failed: `unsafe { *p.add(1) } == 1`"; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a usize, &'b usize, Option>) -> ! {core::panicking::assert_failed::}, val: Value() } + // + literal: Const { ty: &str, val: Value(Slice(..)) } + Retag(_36); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _35 = &(*_36); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _28 = core::panicking::assert_failed::(move _29, move _30, move _32, move _34, move _35); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'a, 'b, 'c, 'd> fn(core::panicking::AssertKind, &'a usize, &'b usize, Option>, &'d str) -> ! {core::panicking::assert_failed::}, val: Value() } } bb4: { From 89dac4c7257c53b660b613b630cc5bb7f2e97469 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 27 Jan 2023 07:32:10 +0000 Subject: [PATCH 3/3] add gate test and bless mir --- .../inline/inline_generator.main.Inline.diff | 108 +++++++++--------- ...ue_59352.num_to_digit.PreCodegen.after.mir | 81 +++++++------ tests/ui/consts/assert_eq_gate.rs | 5 + tests/ui/consts/assert_eq_gate.stderr | 11 ++ 4 files changed, 110 insertions(+), 95 deletions(-) create mode 100644 tests/ui/consts/assert_eq_gate.rs create mode 100644 tests/ui/consts/assert_eq_gate.stderr diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.diff b/tests/mir-opt/inline/inline_generator.main.Inline.diff index aa9deb87d87b5..f27b64c305457 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.diff @@ -7,7 +7,7 @@ let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 let mut _3: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 let mut _4: [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:28: +1:31 -+ let mut _6: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ let mut _7: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 scope 1 { debug _r => _1; // in scope 1 at $DIR/inline_generator.rs:+1:9: +1:11 } @@ -17,15 +17,19 @@ + debug pointer => _3; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL + let mut _5: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL + scope 4 { ++ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL ++ debug pointer => _5; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ let mut _6: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ } + } + } -+ scope 5 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:33: 9:46 -+ debug a => _6; // in scope 5 at $DIR/inline_generator.rs:15:6: 15:7 -+ let mut _7: i32; // in scope 5 at $DIR/inline_generator.rs:15:17: 15:39 -+ let mut _8: u32; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _9: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _11: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ scope 6 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:33: 9:46 ++ debug a => _7; // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7 ++ let mut _8: i32; // in scope 6 at $DIR/inline_generator.rs:15:17: 15:39 ++ let mut _9: u32; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _11: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _12: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 + } bb0: { @@ -44,28 +48,36 @@ + discriminant(_4) = 0; // scope 2 at $DIR/inline_generator.rs:15:5: 15:41 _3 = &mut _4; // scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 - _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 -+ StorageLive(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL -+ _5 = move _3; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL -+ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked(move _5) -> [return: bb3, unwind: bb2]; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL - // mir::Constant +- // mir::Constant - // + span: $DIR/inline_generator.rs:9:14: 9:22 -+ // + span: $SRC_DIR/core/src/pin.rs:LL:COL - // + user_ty: UserType(0) +- // + user_ty: UserType(0) - // + literal: Const { ty: fn(&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new}, val: Value() } -+ // + literal: Const { ty: unsafe fn(&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked}, val: Value() } - } - +- } +- - bb2: { -- StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 ++ StorageLive(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ _5 = move _3; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ StorageLive(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ _6 = move _5; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ Deinit(_2); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ StorageDead(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ StorageDead(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 - _1 = <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46 - // mir::Constant - // + span: $DIR/inline_generator.rs:9:33: 9:39 - // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Yield, <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Return> {<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume}, val: Value() } -- } -- ++ StorageLive(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ _7 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ _9 = discriminant((*_10)); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ switchInt(move _9) -> [0: bb3, 1: bb8, 3: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 + } + - bb3: { + bb1: { -+ StorageDead(_6); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ StorageDead(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 StorageDead(_2); // scope 0 at $DIR/inline_generator.rs:+1:45: +1:46 StorageDead(_4); // scope 0 at $DIR/inline_generator.rs:+1:46: +1:47 _0 = const (); // scope 0 at $DIR/inline_generator.rs:+0:11: +2:2 @@ -79,56 +91,46 @@ + } + + bb3: { -+ StorageDead(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL -+ StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 -+ StorageLive(_6); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _6 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 -+ _8 = discriminant((*_9)); // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 -+ switchInt(move _8) -> [0: bb4, 1: bb9, 3: bb8, otherwise: bb10]; // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ StorageLive(_8); // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 ++ switchInt(move _7) -> [0: bb5, otherwise: bb4]; // scope 6 at $DIR/inline_generator.rs:15:20: 15:21 + } + + bb4: { -+ StorageLive(_7); // scope 5 at $DIR/inline_generator.rs:15:17: 15:39 -+ switchInt(move _6) -> [0: bb6, otherwise: bb5]; // scope 5 at $DIR/inline_generator.rs:15:20: 15:21 ++ _8 = const 7_i32; // scope 6 at $DIR/inline_generator.rs:15:24: 15:25 ++ goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 + } + + bb5: { -+ _7 = const 7_i32; // scope 5 at $DIR/inline_generator.rs:15:24: 15:25 -+ goto -> bb7; // scope 5 at $DIR/inline_generator.rs:15:17: 15:39 ++ _8 = const 13_i32; // scope 6 at $DIR/inline_generator.rs:15:35: 15:37 ++ goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 + } + + bb6: { -+ _7 = const 13_i32; // scope 5 at $DIR/inline_generator.rs:15:35: 15:37 -+ goto -> bb7; // scope 5 at $DIR/inline_generator.rs:15:17: 15:39 ++ Deinit(_1); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ discriminant(_1) = 0; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ _11 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ discriminant((*_11)) = 3; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:11: 15:39 + } + + bb7: { -+ Deinit(_1); // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 -+ ((_1 as Yielded).0: i32) = move _7; // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 -+ discriminant(_1) = 0; // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 -+ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 -+ discriminant((*_10)) = 3; // scope 5 at $DIR/inline_generator.rs:15:11: 15:39 -+ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:11: 15:39 ++ StorageLive(_8); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ StorageDead(_8); // scope 6 at $DIR/inline_generator.rs:15:38: 15:39 ++ Deinit(_1); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ ((_1 as Complete).0: bool) = move _7; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ discriminant(_1) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ _12 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ discriminant((*_12)) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:41: 15:41 + } + + bb8: { -+ StorageLive(_7); // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 -+ StorageDead(_7); // scope 5 at $DIR/inline_generator.rs:15:38: 15:39 -+ Deinit(_1); // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 -+ ((_1 as Complete).0: bool) = move _6; // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 -+ discriminant(_1) = 1; // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 -+ _11 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 -+ discriminant((*_11)) = 1; // scope 5 at $DIR/inline_generator.rs:15:41: 15:41 -+ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:41: 15:41 ++ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 + } + + bb9: { -+ assert(const false, "generator resumed after completion") -> [success: bb9, unwind: bb2]; // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 -+ } -+ -+ bb10: { -+ unreachable; // scope 5 at $DIR/inline_generator.rs:15:5: 15:41 ++ unreachable; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 } } diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index 247ad2100a5cf..c17d221f86a84 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -3,48 +3,51 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; // in scope 0 at $DIR/issue_59352.rs:+0:21: +0:24 let mut _0: u32; // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38 - let mut _2: bool; // in scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 - let mut _3: std::option::Option; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 - let mut _4: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 + let mut _2: std::option::Option; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 + let mut _9: isize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 (inlined char::methods::::is_digit) { // at $DIR/issue_59352.rs:14:12: 14:23 - debug self => _7; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug radix => _4; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _5: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let _6: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _7: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let mut _4: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let _5: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let mut _6: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + scope 2 (inlined Option::::is_some) { // at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug self => _4; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + } } - scope 2 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:42: 14:50 - debug self => _3; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _8: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _9: !; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - scope 3 { - debug val => _0; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:42: 14:50 + debug self => _2; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _8: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + scope 4 { + debug val => _0; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL } } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 - _7 = _1; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:11 - StorageLive(_4); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 + StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 + StorageLive(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageLive(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageLive(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _6 = char::methods::::to_digit(move _7, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _6 = _1; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _5 = char::methods::::to_digit(move _6, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/char/methods.rs:LL:COL // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } } bb1: { - StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 - _3 = char::methods::::to_digit(move _1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + StorageLive(_2); // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + _2 = char::methods::::to_digit(move _1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 // mir::Constant // + span: $DIR/issue_59352.rs:14:30: 14:38 // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } } bb2: { - _8 = discriminant(_3); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _8) -> [0: bb7, 1: bb9, otherwise: bb8]; // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + _7 = discriminant(_2); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _7) -> [0: bb6, 1: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL } bb3: { @@ -53,28 +56,22 @@ fn num_to_digit(_1: char) -> u32 { } bb4: { - StorageDead(_2); // scope 0 at $DIR/issue_59352.rs:+2:62: +2:63 return; // scope 0 at $DIR/issue_59352.rs:+3:2: +3:2 } bb5: { - _5 = &_6; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _2 = Option::::is_some(move _5) -> bb6; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/char/methods.rs:LL:COL - // + literal: Const { ty: for<'a> fn(&'a Option) -> bool {Option::::is_some}, val: Value() } - } - - bb6: { - StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _4 = &_5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageDead(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_4); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - switchInt(move _2) -> [0: bb3, otherwise: bb1]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + _9 = discriminant((*_4)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 + switchInt(move _9) -> [1: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 } - bb7: { - StorageLive(_9); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - _9 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + bb6: { + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _8 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/option.rs:LL:COL // + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value() } @@ -83,13 +80,13 @@ fn num_to_digit(_1: char) -> u32 { // + literal: Const { ty: &str, val: Value(Slice(..)) } } - bb8: { - unreachable; // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + bb7: { + unreachable; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL } - bb9: { - _0 = move ((_3 as Some).0: u32); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:49: +2:50 + bb8: { + _0 = move ((_2 as Some).0: u32); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_2); // scope 0 at $DIR/issue_59352.rs:+2:49: +2:50 goto -> bb4; // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63 } } diff --git a/tests/ui/consts/assert_eq_gate.rs b/tests/ui/consts/assert_eq_gate.rs new file mode 100644 index 0000000000000..5957b32498bef --- /dev/null +++ b/tests/ui/consts/assert_eq_gate.rs @@ -0,0 +1,5 @@ +const _: () = assert_eq!(1, 1); +//~^ ERROR `core::panicking::assert_failed` is not yet stable as a const fn +//~| HELP add `#![feature(const_assert_eq)]` to the crate attributes to enable + +fn main() {} diff --git a/tests/ui/consts/assert_eq_gate.stderr b/tests/ui/consts/assert_eq_gate.stderr new file mode 100644 index 0000000000000..e684c735c0079 --- /dev/null +++ b/tests/ui/consts/assert_eq_gate.stderr @@ -0,0 +1,11 @@ +error: `core::panicking::assert_failed` is not yet stable as a const fn + --> $DIR/assert_eq_gate.rs:1:15 + | +LL | const _: () = assert_eq!(1, 1); + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(const_assert_eq)]` to the crate attributes to enable + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error +