Skip to content

Commit ebd8e1e

Browse files
authored
Unrolled build for rust-lang#136160
Rollup merge of rust-lang#136160 - ShE3py:should-panic-backticks, r=thomcc Remove backticks from `ShouldPanic::YesWithMessage`'s `TrFailedMsg` More legible imo ```rs #[test] #[should_panic = "love"] fn foo() { assert!(1 == 2); } ``` Before: ``` note: panic did not contain expected string panic message: `"assertion failed: 1 == 2"`, expected substring: `"love"` ``` After: ``` note: panic did not contain expected string panic message: "assertion failed: 1 == 2" expected substring: "love" ``` Also removed the comma as `assert_eq!` / `assert_ne!` don't use one. ``@rustbot`` label +A-libtest
2 parents d2eadb7 + 55a419f commit ebd8e1e

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

library/test/src/test_result.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,15 @@ pub(crate) fn calc_result(
6161
} else if let Some(panic_str) = maybe_panic_str {
6262
TestResult::TrFailedMsg(format!(
6363
r#"panic did not contain expected string
64-
panic message: `{panic_str:?}`,
65-
expected substring: `{msg:?}`"#
64+
panic message: {panic_str:?}
65+
expected substring: {msg:?}"#
6666
))
6767
} else {
6868
TestResult::TrFailedMsg(format!(
6969
r#"expected panic with string value,
7070
found non-string value: `{:?}`
71-
expected substring: `{:?}`"#,
72-
(*err).type_id(),
73-
msg
71+
expected substring: {msg:?}"#,
72+
(*err).type_id()
7473
))
7574
}
7675
}

library/test/src/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ fn test_should_panic_bad_message() {
200200
}
201201
let expected = "foobar";
202202
let failed_msg = r#"panic did not contain expected string
203-
panic message: `"an error message"`,
204-
expected substring: `"foobar"`"#;
203+
panic message: "an error message"
204+
expected substring: "foobar""#;
205205
let desc = TestDescAndFn {
206206
desc: TestDesc {
207207
name: StaticTestName("whatever"),
@@ -238,7 +238,7 @@ fn test_should_panic_non_string_message_type() {
238238
let failed_msg = format!(
239239
r#"expected panic with string value,
240240
found non-string value: `{:?}`
241-
expected substring: `"foobar"`"#,
241+
expected substring: "foobar""#,
242242
TypeId::of::<i32>()
243243
);
244244
let desc = TestDescAndFn {

tests/ui/test-attrs/test-should-panic-failed-show-span.run.stdout

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.
1515
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:31:4
1616
---- should_panic_with_substring_panics_with_incorrect_string stdout ----
1717
note: panic did not contain expected string
18-
panic message: `"ZOMGWTFBBQ"`,
19-
expected substring: `"message"`
18+
panic message: "ZOMGWTFBBQ"
19+
expected substring: "message"
2020
---- should_panic_with_substring_panics_with_non_string_value stdout ----
2121
note: expected panic with string value,
2222
found non-string value: `TypeId($HEX)`
23-
expected substring: `"message"`
23+
expected substring: "message"
2424

2525
failures:
2626
should_panic_with_any_message_does_not_panic

0 commit comments

Comments
 (0)