Rollup merge of #83081 - hyd-dev:assert-message, r=m-ou-se

Fix panic message of `assert_failed_inner`

cc https://github.com/rust-lang/rust/pull/79100#discussion_r593731020

r? ``@m-ou-se``
This commit is contained in:
Yuki Okushi 2021-03-14 13:07:37 +09:00 committed by GitHub
commit f8206ac63d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

View File

@ -154,7 +154,7 @@ fn assert_failed_inner(
Some(args) => panic!(
r#"assertion failed: `(left {} right)`
left: `{:?}`,
right: `{:?}: {}`"#,
right: `{:?}`: {}"#,
op, left, right, args
),
None => panic!(

View File

@ -0,0 +1,9 @@
// run-fail
// error-pattern:panicked at 'assertion failed: `(left == right)`
// error-pattern: left: `2`
// error-pattern:right: `3`: 1 + 1 definitely should be 3'
// ignore-emscripten no processes
fn main() {
assert_eq!(1 + 1, 3, "1 + 1 definitely should be 3");
}

View File

@ -0,0 +1,11 @@
// 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'
// ignore-emscripten no processes
#![feature(assert_matches)]
fn main() {
assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3");
}

View File

@ -0,0 +1,9 @@
// 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'
// ignore-emscripten no processes
fn main() {
assert_ne!(1 + 1, 2, "1 + 1 definitely should not be 2");
}