diff options
| author | Benoît du Garreau <bdgdlm@outlook.com> | 2020-12-16 22:06:06 +0100 |
|---|---|---|
| committer | Benoît du Garreau <bdgdlm@outlook.com> | 2021-02-14 23:39:42 +0100 |
| commit | 546d062820555d5597c63288340feed17cea54f9 (patch) | |
| tree | 18c61f3876477739a80d1fe5d98f9ac5532c9738 | |
| parent | f138e260a00ac16e8532aa406f6738c92e5d27ff (diff) | |
| download | rust-546d062820555d5597c63288340feed17cea54f9.tar.gz rust-546d062820555d5597c63288340feed17cea54f9.zip | |
Apply suggestions
- Move `assert_failed` to core::panicking` - Make `assert_failed` use an enum instead of a string
| -rw-r--r-- | library/core/src/lib.rs | 7 | ||||
| -rw-r--r-- | library/core/src/macros/internals.rs | 35 | ||||
| -rw-r--r-- | library/core/src/macros/mod.rs | 20 | ||||
| -rw-r--r-- | library/core/src/panicking.rs | 49 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff | 24 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff | 23 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff | 53 | ||||
| -rw-r--r-- | src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff | 58 | ||||
| -rw-r--r-- | src/test/ui/binop/issue-77910-1.stderr | 7 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-59488.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr | 4 |
11 files changed, 163 insertions, 121 deletions
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index cc74656a296..fd4a76c1eb5 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -173,13 +173,6 @@ mod macros; #[macro_use] mod internal_macros; -#[doc(hidden)] -#[unstable( - feature = "macros_internals", - reason = "macros implementation detail", - issue = "none" -)] -pub use macros::internals as macros_internals; #[path = "num/shells/int_macros.rs"] #[macro_use] diff --git a/library/core/src/macros/internals.rs b/library/core/src/macros/internals.rs deleted file mode 100644 index c3ad7398aa1..00000000000 --- a/library/core/src/macros/internals.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::{fmt, panic}; - -#[cold] -#[doc(hidden)] -#[unstable(feature = "macros_internals", reason = "macros implementation detail", issue = "none")] -#[track_caller] -pub fn assert_failed<T, U>(op: &str, left: &T, right: &U, args: Option<fmt::Arguments<'_>>) -> ! -where - T: fmt::Debug + ?Sized, - U: fmt::Debug + ?Sized, -{ - #[track_caller] - fn inner( - op: &str, - left: &dyn fmt::Debug, - right: &dyn fmt::Debug, - args: Option<fmt::Arguments<'_>>, - ) -> ! { - match args { - Some(args) => panic!( - r#"assertion failed: `(left {} right)` - left: `{:?}`, - right: `{:?}: {}`"#, - op, left, right, args - ), - None => panic!( - r#"assertion failed: `(left {} right)` - left: `{:?}`, - right: `{:?}`"#, - op, left, right, - ), - } - } - inner(op, &left, &right, args) -} diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index f505b7021ed..6eee9948e7c 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1,7 +1,3 @@ -#[unstable(feature = "macros_internals", reason = "macros implementation detail", issue = "none")] -#[doc(hidden)] -pub mod internals; - #[cfg(bootstrap)] #[doc(include = "panic.md")] #[macro_export] @@ -57,16 +53,17 @@ macro_rules! panic { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[allow_internal_unstable(macros_internals)] +#[allow_internal_unstable(core_panic)] macro_rules! assert_eq { ($left:expr, $right:expr $(,)?) => ({ match (&$left, &$right) { (left_val, right_val) => { if !(*left_val == *right_val) { + let kind = $crate::panicking::AssertKind::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::macros_internals::assert_failed("==", &*left_val, &*right_val, $crate::option::Option::None); + $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::None); } } } @@ -75,10 +72,11 @@ macro_rules! assert_eq { match (&$left, &$right) { (left_val, right_val) => { if !(*left_val == *right_val) { + let kind = $crate::panicking::AssertKind::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::macros_internals::assert_failed("==", &*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)+))); } } } @@ -104,16 +102,17 @@ macro_rules! assert_eq { /// ``` #[macro_export] #[stable(feature = "assert_ne", since = "1.13.0")] -#[allow_internal_unstable(macros_internals)] +#[allow_internal_unstable(core_panic)] macro_rules! assert_ne { ($left:expr, $right:expr $(,)?) => ({ match (&$left, &$right) { (left_val, right_val) => { if *left_val == *right_val { + let kind = $crate::panicking::AssertKind::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::macros_internals::assert_failed("!=", &*left_val, &*right_val, $crate::option::Option::None); + $crate::panicking::assert_failed(kind, &*left_val, &*right_val, $crate::option::Option::None); } } } @@ -122,10 +121,11 @@ macro_rules! assert_ne { match (&($left), &($right)) { (left_val, right_val) => { if *left_val == *right_val { + let kind = $crate::panicking::AssertKind::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::macros_internals::assert_failed("!=", &*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)+))); } } } diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 25651502510..36ae2449447 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -91,3 +91,52 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { // SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call. unsafe { panic_impl(&pi) } } + +#[derive(Debug)] +pub enum AssertKind { + Eq, + Ne, +} + +/// Internal function for `assert_eq!` and `assert_ne!` macros +#[cold] +#[track_caller] +pub fn assert_failed<T, U>( + kind: AssertKind, + left: &T, + right: &U, + args: Option<fmt::Arguments<'_>>, +) -> ! +where + T: fmt::Debug + ?Sized, + U: fmt::Debug + ?Sized, +{ + #[track_caller] + fn inner( + kind: AssertKind, + left: &dyn fmt::Debug, + right: &dyn fmt::Debug, + args: Option<fmt::Arguments<'_>>, + ) -> ! { + let op = match kind { + AssertKind::Eq => "==", + AssertKind::Ne => "!=", + }; + + match args { + Some(args) => panic!( + r#"assertion failed: `(left {} right)` + left: `{:?}`, + right: `{:?}: {}`"#, + op, left, right, args + ), + None => panic!( + r#"assertion failed: `(left {} right)` + left: `{:?}`, + right: `{:?}`"#, + op, left, right, + ), + } + } + inner(kind, &left, &right, args) +} diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index 46404f5e33c..c630ab70de1 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -11,7 +11,6 @@ let mut _7: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _8: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _9: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _10: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _12: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _13: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -23,6 +22,10 @@ scope 4 { debug left_val => _11; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _12; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _10: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 5 { + debug kind => _10; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } } } } @@ -65,19 +68,20 @@ } bb1: { - _10 = const "=="; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - // ty::Const - // + ty: &str - // + val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) + StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_10) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_13) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _11, move _12, move _13); // 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: &str, val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) } - StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_13) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::macros::internals::assert_failed::<i32, i32>(move _10, move _11, move _12, move _13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option<std::fmt::Arguments<'t0>>) -> ! {core::panicking::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: core::panicking::AssertKind + // + val: Value(Scalar(0x00)) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'r, 's, 't0, 't1> fn(&'r str, &'s i32, &'t0 i32, std::option::Option<std::fmt::Arguments<'t1>>) -> ! {core::macros::internals::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } } bb2: { diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index 64b559f6432..c630ab70de1 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -11,9 +11,9 @@ let mut _7: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _8: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _9: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _10: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _12: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _13: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _4: std::option::Option<i32>; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 @@ -22,6 +22,10 @@ scope 4 { debug left_val => _11; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _12; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _10: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 5 { + debug kind => _10; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } } } } @@ -64,17 +68,20 @@ } bb1: { - _10 = const "=="; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - // ty::Const - // + ty: &str - // + val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) + StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_10) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_13) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _11, move _12, move _13); // 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: &str, val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) } - core::macros::internals::assert_failed::<i32, i32>(move _10, move _11, move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option<std::fmt::Arguments<'t0>>) -> ! {core::panicking::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: core::panicking::AssertKind + // + val: Value(Scalar(0x00)) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'r, 's, 't0> fn(&'r str, &'s i32, &'t0 i32) -> ! {core::macros::internals::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } } bb2: { diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index cf1db80bcfc..bd24522271b 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -19,9 +19,8 @@ let mut _17: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _20: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _21: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _22: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _21: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _22: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _23: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -38,6 +37,10 @@ scope 4 { debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _20: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 5 { + debug kind => _20; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } } } } @@ -110,30 +113,36 @@ bb3: { StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_22); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _22 = const "=="; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _22 = const core::panicking::AssertKind::Eq; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const - // + ty: &str - // + val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) + // + ty: core::panicking::AssertKind + // + val: Value(Scalar(0x00)) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) } - _21 = _22; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_23); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = _13; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = _24; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_26); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _26 = _14; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _25 = _26; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_27) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::macros::internals::assert_failed::<i32, i32>(move _21, move _23, move _25, move _27); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } + StorageLive(_23); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_24); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _24 = _13; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _23 = _24; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_25); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_26); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _26 = _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _25 = _26; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // 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: for<'r, 's, 't0, 't1> fn(&'r str, &'s i32, &'t0 i32, std::option::Option<std::fmt::Arguments<'t1>>) -> ! {core::macros::internals::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option<std::fmt::Arguments<'t0>>) -> ! {core::panicking::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: core::panicking::AssertKind + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } } bb4: { diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index 3d19385c343..bd24522271b 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -19,13 +19,13 @@ let mut _17: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _20: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _21: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _22: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _21: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _22: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _23: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _26: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _27: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _6: std::option::Option<i32>; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 @@ -33,10 +33,14 @@ debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _27: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _28: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _20: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 5 { + debug kind => _20; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } } } } @@ -77,14 +81,14 @@ StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _27 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _28 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) } - _11 = _27; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = _28; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -109,28 +113,36 @@ bb3: { StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_22); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _22 = const "=="; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_20) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _22 = const core::panicking::AssertKind::Eq; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const - // + ty: &str - // + val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) + // + ty: core::panicking::AssertKind + // + val: Value(Scalar(0x00)) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [61, 61], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) } - _21 = _22; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_23); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = _13; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = _24; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_26); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _26 = _14; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _25 = _26; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::macros::internals::assert_failed::<i32, i32>(move _21, move _23, move _25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } + StorageLive(_23); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_24); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _24 = _13; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _23 = _24; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_25); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_26); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _26 = _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _25 = _26; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // 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: for<'r, 's, 't0> fn(&'r str, &'s i32, &'t0 i32) -> ! {core::macros::internals::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option<std::fmt::Arguments<'t0>>) -> ! {core::panicking::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: core::panicking::AssertKind + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } } bb4: { diff --git a/src/test/ui/binop/issue-77910-1.stderr b/src/test/ui/binop/issue-77910-1.stderr index e48d3e19996..2c6d5727527 100644 --- a/src/test/ui/binop/issue-77910-1.stderr +++ b/src/test/ui/binop/issue-77910-1.stderr @@ -14,10 +14,13 @@ error[E0277]: `for<'r> fn(&'r i32) -> &'r i32 {foo}` doesn't implement `Debug` | LL | assert_eq!(foo, y); | ^^^^^^^^^^^^^^^^^^^ `for<'r> fn(&'r i32) -> &'r i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | + ::: $SRC_DIR/core/src/panicking.rs:LL:COL + | +LL | T: fmt::Debug + ?Sized, + | ---------- required by this bound in `core::panicking::assert_failed` | = help: the trait `Debug` is not implemented for `for<'r> fn(&'r i32) -> &'r i32 {foo}` - = note: required because of the requirements on the impl of `Debug` for `&for<'r> fn(&'r i32) -> &'r i32 {foo}` - = note: required by `std::fmt::Debug::fmt` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-59488.stderr b/src/test/ui/issues/issue-59488.stderr index 43a6517c8ca..2627724f877 100644 --- a/src/test/ui/issues/issue-59488.stderr +++ b/src/test/ui/issues/issue-59488.stderr @@ -85,10 +85,10 @@ error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - ::: $SRC_DIR/core/src/macros/internals.rs:LL:COL + ::: $SRC_DIR/core/src/panicking.rs:LL:COL | LL | T: fmt::Debug + ?Sized, - | ---------- required by this bound in `core::macros::internals::assert_failed` + | ---------- required by this bound in `core::panicking::assert_failed` | = help: the trait `Debug` is not implemented for `fn(usize) -> Foo {Foo::Bar}` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr b/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr index 5623b331f71..20e4b107681 100644 --- a/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr +++ b/src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr @@ -29,10 +29,10 @@ LL | fn a() -> i32 { LL | assert_eq!(a, 0); | ^^^^^^^^^^^^^^^^^ `fn() -> i32 {a}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - ::: $SRC_DIR/core/src/macros/internals.rs:LL:COL + ::: $SRC_DIR/core/src/panicking.rs:LL:COL | LL | T: fmt::Debug + ?Sized, - | ---------- required by this bound in `core::macros::internals::assert_failed` + | ---------- required by this bound in `core::panicking::assert_failed` | = help: the trait `Debug` is not implemented for `fn() -> i32 {a}` = help: use parentheses to call the function: `a()` |
