diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 7c93c93b4a019..e3bb0c1102df4 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -38,11 +38,11 @@ macro_rules! assert_eq { match (&$left, &$right) { (left_val, right_val) => { if !(*left_val == *right_val) { - let kind = $crate::panicking::AssertKind::Eq; + let assert = $crate::concat!($crate::stringify!($left), " == ", $crate::stringify!($right)); // 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(assert, &*left_val, &*right_val, $crate::option::Option::None); } } } @@ -51,11 +51,11 @@ macro_rules! assert_eq { match (&$left, &$right) { (left_val, right_val) => { if !(*left_val == *right_val) { - let kind = $crate::panicking::AssertKind::Eq; + let assert = $crate::concat!($crate::stringify!($left), " == ", $crate::stringify!($right)); // 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(assert, &*left_val, &*right_val, $crate::option::Option::Some($crate::format_args!($($arg)+))); } } } @@ -88,11 +88,11 @@ macro_rules! assert_ne { match (&$left, &$right) { (left_val, right_val) => { if *left_val == *right_val { - let kind = $crate::panicking::AssertKind::Ne; + let assert = $crate::concat!($crate::stringify!($left), " != ", $crate::stringify!($right)); // 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(assert, &*left_val, &*right_val, $crate::option::Option::None); } } } @@ -101,11 +101,11 @@ macro_rules! assert_ne { match (&($left), &($right)) { (left_val, right_val) => { if *left_val == *right_val { - let kind = $crate::panicking::AssertKind::Ne; + let assert = $crate::concat!($crate::stringify!($left), " != ", $crate::stringify!($right)); // 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(assert, &*left_val, &*right_val, $crate::option::Option::Some($crate::format_args!($($arg)+))); } } } @@ -146,10 +146,12 @@ pub macro assert_matches { match $left { $( $pattern )|+ $( if $guard )? => {} ref left_val => { + let assert = $crate::concat!($crate::stringify!($left), " matches ", $crate::stringify!($($pattern)|+ $(if $guard)?)); $crate::panicking::assert_matches_failed( left_val, $crate::stringify!($($pattern)|+ $(if $guard)?), - $crate::option::Option::None + $crate::option::Option::None, + assert, ); } } @@ -158,10 +160,12 @@ pub macro assert_matches { match $left { $( $pattern )|+ $( if $guard )? => {} ref left_val => { + let assert = $crate::concat!($crate::stringify!($left), " matches ", $crate::stringify!($($pattern)|+ $(if $guard)?)); $crate::panicking::assert_matches_failed( left_val, $crate::stringify!($($pattern)|+ $(if $guard)?), - $crate::option::Option::Some($crate::format_args!($($arg)+)) + $crate::option::Option::Some($crate::format_args!($($arg)+)), + assert, ); } } diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 81be3fb22eec4..304dc214b1a13 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -202,21 +202,13 @@ pub const fn const_panic_fmt(fmt: fmt::Arguments<'_>) -> ! { } } -#[derive(Debug)] -#[doc(hidden)] -pub enum AssertKind { - Eq, - Ne, - Match, -} - /// Internal function for `assert_eq!` and `assert_ne!` macros #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold)] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] #[doc(hidden)] pub fn assert_failed( - kind: AssertKind, + assert_msg: &'static str, left: &T, right: &U, args: Option>, @@ -225,7 +217,7 @@ where T: fmt::Debug + ?Sized, U: fmt::Debug + ?Sized, { - assert_failed_inner(kind, &left, &right, args) + assert_failed_inner(assert_msg, &left, &right, args) } /// Internal function for `assert_match!` @@ -237,6 +229,7 @@ pub fn assert_matches_failed( left: &T, right: &str, args: Option>, + assert_msg: &'static str, ) -> ! { // The pattern is a string so it can be displayed directly. struct Pattern<'a>(&'a str); @@ -245,7 +238,7 @@ pub fn assert_matches_failed( f.write_str(self.0) } } - assert_failed_inner(AssertKind::Match, &left, &Pattern(right), args); + assert_failed_inner(assert_msg, &left, &Pattern(right), args); } /// Non-generic version of the above functions, to avoid code bloat. @@ -253,29 +246,22 @@ pub fn assert_matches_failed( #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] fn assert_failed_inner( - kind: AssertKind, + assert_msg: &'static str, left: &dyn fmt::Debug, right: &dyn fmt::Debug, args: Option>, ) -> ! { - let op = match kind { - AssertKind::Eq => "==", - AssertKind::Ne => "!=", - AssertKind::Match => "matches", - }; - match args { Some(args) => panic!( - r#"assertion failed: `(left {} right)` - left: `{:?}`, - right: `{:?}`: {}"#, - op, left, right, args + r#"assertion failed: `{assert_msg}` + error: {args} + left: `{left:?}` + right: `{right:?}`"# ), None => panic!( - r#"assertion failed: `(left {} right)` - left: `{:?}`, - right: `{:?}`"#, - op, left, right, + r#"assertion failed: `{assert_msg}` + left: `{left:?}` + right: `{right:?}`"# ), } } diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index a46a29cbad608..6bcbcb6e800cf 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -257,7 +257,11 @@ fn default_hook(info: &PanicInfo<'_>) { let name = thread.as_ref().and_then(|t| t.name()).unwrap_or(""); let write = |err: &mut dyn crate::io::Write| { - let _ = writeln!(err, "thread '{name}' panicked at '{msg}', {location}"); + if msg.contains('\n') { + let _ = writeln!(err, "thread '{name}' panicked at {location}:\n{msg}"); + } else { + let _ = writeln!(err, "thread '{name}' panicked at '{msg}', {location}"); + } static FIRST_PANIC: AtomicBool = AtomicBool::new(true); diff --git a/src/tools/clippy/clippy_utils/src/macros.rs b/src/tools/clippy/clippy_utils/src/macros.rs index 62d388a5ece8d..9273bdbb5bdc5 100644 --- a/src/tools/clippy/clippy_utils/src/macros.rs +++ b/src/tools/clippy/clippy_utils/src/macros.rs @@ -238,6 +238,7 @@ impl<'a> PanicExpn<'a> { "assert_failed" => { // It should have 4 arguments in total (we already matched with the first argument, // so we're just checking for 3) + // Since Rust 1.70, `assert_failed` has two additional args. if rest.len() != 3 { return None; } diff --git a/tests/mir-opt/issue_99325.main.built.after.mir b/tests/mir-opt/issue_99325.main.built.after.mir index f0c9ef419bd89..483c45e60de21 100644 --- a/tests/mir-opt/issue_99325.main.built.after.mir +++ b/tests/mir-opt/issue_99325.main.built.after.mir @@ -21,7 +21,7 @@ fn main() -> () { let mut _13: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _14: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _16: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _17: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _17: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _18: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _19: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _20: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -41,7 +41,7 @@ fn main() -> () { 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 _38: &str; // 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 @@ -50,17 +50,17 @@ fn main() -> () { 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 - let _15: core::panicking::AssertKind; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _15: &str; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 2 { - debug kind => _15; // in scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug assert => _15; // in scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } 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 + let _36: &str; // 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 assert => _36; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } @@ -114,11 +114,14 @@ fn main() -> () { bb3: { StorageLive(_15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _15 = core::panicking::AssertKind::Eq; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = const "function_with_bytes::() == &[0x41, 0x41, 0x41, 0x41]"; // scope 1 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(..)) } FakeRead(ForLet(None), _15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_16); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_17); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = move _15; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = &(*_15); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_18); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _19 = &(*_8); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -132,7 +135,7 @@ fn main() -> () { _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 // 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> fn(&'static str, &'a &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } } bb4: { @@ -223,11 +226,14 @@ fn main() -> () { 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 + _36 = const "function_with_bytes::<{ &[0x41, 0x41, 0x41, 0x41] }>() == b\"AAAA\""; // 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: &str, val: Value(Slice(..)) } 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 + _38 = &(*_36); // scope 4 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 @@ -241,7 +247,7 @@ fn main() -> () { _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 // 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> fn(&'static str, &'a &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } } bb13: { 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 3b479710b4f2d..2e84e8d1e5750 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 @@ -24,7 +24,7 @@ fn array_casts() -> () { let mut _25: usize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _26: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _28: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _29: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _29: &str; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _30: &usize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _31: &usize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _32: &usize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -51,9 +51,9 @@ fn array_casts() -> () { scope 7 { debug left_val => _20; // in scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _21; // in scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _27: core::panicking::AssertKind; // in scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _27: &str; // in scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 8 { - debug kind => _27; // in scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug assert => _27; // in scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } } @@ -148,10 +148,14 @@ fn array_casts() -> () { bb3: { StorageLive(_27); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _27 = core::panicking::AssertKind::Eq; // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _27 = const "unsafe { *p.add(1) } == 1"; // scope 7 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(..)) } + Retag(_27); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_28); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_29); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _29 = move _27; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _29 = &(*_27); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_30); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_31); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _31 = &(*_20); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -166,7 +170,7 @@ fn array_casts() -> () { _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 // 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: for<'a, 'b, 'c> fn(&'static str, &'a usize, &'b usize, Option>) -> ! {core::panicking::assert_failed::}, val: Value() } } bb4: { diff --git a/tests/ui/macros/assert-eq-macro-msg.rs b/tests/ui/macros/assert-eq-macro-msg.rs index accbd2d1e7f50..7657d9c14375f 100644 --- a/tests/ui/macros/assert-eq-macro-msg.rs +++ b/tests/ui/macros/assert-eq-macro-msg.rs @@ -1,7 +1,5 @@ // run-fail -// error-pattern:panicked at 'assertion failed: `(left == right)` -// error-pattern: left: `2` -// error-pattern:right: `3`: 1 + 1 definitely should be 3' +// check-run-results // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-eq-macro-msg.run.stderr b/tests/ui/macros/assert-eq-macro-msg.run.stderr new file mode 100644 index 0000000000000..3283734dcd4cd --- /dev/null +++ b/tests/ui/macros/assert-eq-macro-msg.run.stderr @@ -0,0 +1,6 @@ +thread 'main' panicked at $DIR/assert-eq-macro-msg.rs:6:5: +assertion failed: `1 + 1 == 3` + error: 1 + 1 definitely should be 3 + left: `2` + right: `3` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/macros/assert-eq-macro-panic.rs b/tests/ui/macros/assert-eq-macro-panic.rs index 5e505c30b3503..72cf184afeaaf 100644 --- a/tests/ui/macros/assert-eq-macro-panic.rs +++ b/tests/ui/macros/assert-eq-macro-panic.rs @@ -1,7 +1,5 @@ // run-fail -// error-pattern:assertion failed: `(left == right)` -// error-pattern: left: `14` -// error-pattern:right: `15` +// check-run-results // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-eq-macro-panic.run.stderr b/tests/ui/macros/assert-eq-macro-panic.run.stderr new file mode 100644 index 0000000000000..065576dd05286 --- /dev/null +++ b/tests/ui/macros/assert-eq-macro-panic.run.stderr @@ -0,0 +1,5 @@ +thread 'main' panicked at $DIR/assert-eq-macro-panic.rs:6:5: +assertion failed: `14 == 15` + left: `14` + right: `15` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/macros/assert-eq-macro-vars.rs b/tests/ui/macros/assert-eq-macro-vars.rs new file mode 100644 index 0000000000000..18253bd4c73b3 --- /dev/null +++ b/tests/ui/macros/assert-eq-macro-vars.rs @@ -0,0 +1,8 @@ +// run-fail +// check-run-results +// ignore-emscripten no processes + +fn main() { + let var = 2; + assert_eq!(var * 2, 3); +} diff --git a/tests/ui/macros/assert-eq-macro-vars.run.stderr b/tests/ui/macros/assert-eq-macro-vars.run.stderr new file mode 100644 index 0000000000000..09d70fd7425ea --- /dev/null +++ b/tests/ui/macros/assert-eq-macro-vars.run.stderr @@ -0,0 +1,5 @@ +thread 'main' panicked at $DIR/assert-eq-macro-vars.rs:7:5: +assertion failed: `var * 2 == 3` + left: `4` + right: `3` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/macros/assert-matches-macro-msg.rs b/tests/ui/macros/assert-matches-macro-msg.rs index fd8cd5a1a0566..8beb7346cf187 100644 --- a/tests/ui/macros/assert-matches-macro-msg.rs +++ b/tests/ui/macros/assert-matches-macro-msg.rs @@ -1,7 +1,5 @@ // run-fail -// error-pattern:panicked at 'assertion failed: `(left matches right)` -// error-pattern: left: `2` -// error-pattern:right: `3`: 1 + 1 definitely should be 3' +// check-run-results // ignore-emscripten no processes #![feature(assert_matches)] diff --git a/tests/ui/macros/assert-matches-macro-msg.run.stderr b/tests/ui/macros/assert-matches-macro-msg.run.stderr new file mode 100644 index 0000000000000..2cfc4da8c7701 --- /dev/null +++ b/tests/ui/macros/assert-matches-macro-msg.run.stderr @@ -0,0 +1,6 @@ +thread 'main' panicked at $DIR/assert-matches-macro-msg.rs:10:5: +assertion failed: `1 + 1 matches 3` + error: 1 + 1 definitely should be 3 + left: `2` + right: `3` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/macros/assert-ne-macro-msg.rs b/tests/ui/macros/assert-ne-macro-msg.rs index fc0472b99b428..5ddf5527f82b4 100644 --- a/tests/ui/macros/assert-ne-macro-msg.rs +++ b/tests/ui/macros/assert-ne-macro-msg.rs @@ -1,7 +1,5 @@ // run-fail -// error-pattern:panicked at 'assertion failed: `(left != right)` -// error-pattern: left: `2` -// error-pattern:right: `2`: 1 + 1 definitely should not be 2' +// check-run-results // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-ne-macro-msg.run.stderr b/tests/ui/macros/assert-ne-macro-msg.run.stderr new file mode 100644 index 0000000000000..15b3de651ea01 --- /dev/null +++ b/tests/ui/macros/assert-ne-macro-msg.run.stderr @@ -0,0 +1,6 @@ +thread 'main' panicked at $DIR/assert-ne-macro-msg.rs:6:5: +assertion failed: `1 + 1 != 2` + error: 1 + 1 definitely should not be 2 + left: `2` + right: `2` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/macros/assert-ne-macro-panic.rs b/tests/ui/macros/assert-ne-macro-panic.rs index 4f507d7b54d99..137b27ee9e121 100644 --- a/tests/ui/macros/assert-ne-macro-panic.rs +++ b/tests/ui/macros/assert-ne-macro-panic.rs @@ -1,7 +1,5 @@ // run-fail -// error-pattern:assertion failed: `(left != right)` -// error-pattern: left: `14` -// error-pattern:right: `14` +// check-run-results // ignore-emscripten no processes fn main() { diff --git a/tests/ui/macros/assert-ne-macro-panic.run.stderr b/tests/ui/macros/assert-ne-macro-panic.run.stderr new file mode 100644 index 0000000000000..9216d2077e88f --- /dev/null +++ b/tests/ui/macros/assert-ne-macro-panic.run.stderr @@ -0,0 +1,5 @@ +thread 'main' panicked at $DIR/assert-ne-macro-panic.rs:6:5: +assertion failed: `14 != 14` + left: `14` + right: `14` +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr index 727e9691c53a1..580aedff79077 100644 --- a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr @@ -1,9 +1,11 @@ -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `2`, - right: `4`', $DIR/test-panic-abort-nocapture.rs:33:5 +thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:33:5: +assertion failed: `1 + 1 == 4` + left: `2` + right: `4` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `2`, - right: `4`', $DIR/test-panic-abort-nocapture.rs:27:5 +thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:27:5: +assertion failed: `1 + 1 == 4` + left: `2` + right: `4` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace testing321 diff --git a/tests/ui/test-attrs/test-panic-abort.run.stdout b/tests/ui/test-attrs/test-panic-abort.run.stdout index f608a8cdc5569..e83d6a091b0ed 100644 --- a/tests/ui/test-attrs/test-panic-abort.run.stdout +++ b/tests/ui/test-attrs/test-panic-abort.run.stdout @@ -16,9 +16,10 @@ hello, world testing123 ---- it_fails stderr ---- testing321 -thread 'main' panicked at 'assertion failed: `(left == right)` - left: `2`, - right: `5`', $DIR/test-panic-abort.rs:34:5 +thread 'main' panicked at $DIR/test-panic-abort.rs:34:5: +assertion failed: `1 + 1 == 5` + left: `2` + right: `5` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace