Skip to content

Commit 535f487

Browse files
committed
Allow/fix non_fmt_panic in tests.
1 parent 91a9866 commit 535f487

File tree

13 files changed

+42
-35
lines changed

13 files changed

+42
-35
lines changed

library/term/src/terminfo/parm/tests.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ fn test_comparison_ops() {
7777
for &(op, bs) in v.iter() {
7878
let s = format!("%{{1}}%{{2}}%{}%d", op);
7979
let res = expand(s.as_bytes(), &[], &mut Variables::new());
80-
assert!(res.is_ok(), res.unwrap_err());
80+
assert!(res.is_ok(), "{}", res.unwrap_err());
8181
assert_eq!(res.unwrap(), vec![b'0' + bs[0]]);
8282
let s = format!("%{{1}}%{{1}}%{}%d", op);
8383
let res = expand(s.as_bytes(), &[], &mut Variables::new());
84-
assert!(res.is_ok(), res.unwrap_err());
84+
assert!(res.is_ok(), "{}", res.unwrap_err());
8585
assert_eq!(res.unwrap(), vec![b'0' + bs[1]]);
8686
let s = format!("%{{2}}%{{1}}%{}%d", op);
8787
let res = expand(s.as_bytes(), &[], &mut Variables::new());
88-
assert!(res.is_ok(), res.unwrap_err());
88+
assert!(res.is_ok(), "{}", res.unwrap_err());
8989
assert_eq!(res.unwrap(), vec![b'0' + bs[2]]);
9090
}
9191
}
@@ -95,13 +95,13 @@ fn test_conditionals() {
9595
let mut vars = Variables::new();
9696
let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m";
9797
let res = expand(s, &[Number(1)], &mut vars);
98-
assert!(res.is_ok(), res.unwrap_err());
98+
assert!(res.is_ok(), "{}", res.unwrap_err());
9999
assert_eq!(res.unwrap(), "\\E[31m".bytes().collect::<Vec<_>>());
100100
let res = expand(s, &[Number(8)], &mut vars);
101-
assert!(res.is_ok(), res.unwrap_err());
101+
assert!(res.is_ok(), "{}", res.unwrap_err());
102102
assert_eq!(res.unwrap(), "\\E[90m".bytes().collect::<Vec<_>>());
103103
let res = expand(s, &[Number(42)], &mut vars);
104-
assert!(res.is_ok(), res.unwrap_err());
104+
assert!(res.is_ok(), "{}", res.unwrap_err());
105105
assert_eq!(res.unwrap(), "\\E[38;5;42m".bytes().collect::<Vec<_>>());
106106
}
107107

library/test/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn test_should_panic_bad_message() {
199199
fn test_should_panic_non_string_message_type() {
200200
use crate::tests::TrFailedMsg;
201201
fn f() {
202-
panic!(1i32);
202+
std::panic::panic_any(1i32);
203203
}
204204
let expected = "foobar";
205205
let failed_msg = format!(

src/test/ui-fulldeps/issue-15149.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn test() {
5050
.output().unwrap();
5151

5252
assert!(child_output.status.success(),
53-
format!("child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
54-
str::from_utf8(&child_output.stdout).unwrap(),
55-
str::from_utf8(&child_output.stderr).unwrap()));
53+
"child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
54+
str::from_utf8(&child_output.stdout).unwrap(),
55+
str::from_utf8(&child_output.stderr).unwrap());
5656
}

src/test/ui/consts/const-eval/const_panic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(const_panic)]
2+
#![allow(non_fmt_panic)]
23
#![crate_type = "lib"]
34

45
const MSG: &str = "hello";

src/test/ui/consts/const-eval/const_panic.stderr

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
11
error: any use of this value will cause an error
2-
--> $DIR/const_panic.rs:6:15
2+
--> $DIR/const_panic.rs:7:15
33
|
44
LL | const Z: () = std::panic!("cheese");
55
| --------------^^^^^^^^^^^^^^^^^^^^^-
66
| |
7-
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15
7+
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15
88
|
99
= note: `#[deny(const_err)]` on by default
1010
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1111

1212
error: any use of this value will cause an error
13-
--> $DIR/const_panic.rs:9:16
13+
--> $DIR/const_panic.rs:10:16
1414
|
1515
LL | const Z2: () = std::panic!();
1616
| ---------------^^^^^^^^^^^^^-
1717
| |
18-
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16
18+
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16
1919
|
2020
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2121

2222
error: any use of this value will cause an error
23-
--> $DIR/const_panic.rs:12:15
23+
--> $DIR/const_panic.rs:13:15
2424
|
2525
LL | const Y: () = std::unreachable!();
2626
| --------------^^^^^^^^^^^^^^^^^^^-
2727
| |
28-
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15
28+
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:13:15
2929
|
3030
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3131

3232
error: any use of this value will cause an error
33-
--> $DIR/const_panic.rs:15:15
33+
--> $DIR/const_panic.rs:16:15
3434
|
3535
LL | const X: () = std::unimplemented!();
3636
| --------------^^^^^^^^^^^^^^^^^^^^^-
3737
| |
38-
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15
38+
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:16:15
3939
|
4040
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
4141

4242
error: any use of this value will cause an error
43-
--> $DIR/const_panic.rs:18:15
43+
--> $DIR/const_panic.rs:19:15
4444
|
4545
LL | const W: () = std::panic!(MSG);
4646
| --------------^^^^^^^^^^^^^^^^-
4747
| |
48-
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15
48+
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:19:15
4949
|
5050
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
5151

5252
error: any use of this value will cause an error
53-
--> $DIR/const_panic.rs:21:20
53+
--> $DIR/const_panic.rs:22:20
5454
|
5555
LL | const Z_CORE: () = core::panic!("cheese");
5656
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
5757
| |
58-
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:21:20
58+
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:22:20
5959
|
6060
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
6161

6262
error: any use of this value will cause an error
63-
--> $DIR/const_panic.rs:24:21
63+
--> $DIR/const_panic.rs:25:21
6464
|
6565
LL | const Z2_CORE: () = core::panic!();
6666
| --------------------^^^^^^^^^^^^^^-
6767
| |
68-
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:24:21
68+
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:25:21
6969
|
7070
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
7171

7272
error: any use of this value will cause an error
73-
--> $DIR/const_panic.rs:27:20
73+
--> $DIR/const_panic.rs:28:20
7474
|
7575
LL | const Y_CORE: () = core::unreachable!();
7676
| -------------------^^^^^^^^^^^^^^^^^^^^-
7777
| |
78-
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:27:20
78+
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:28:20
7979
|
8080
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
8181

8282
error: any use of this value will cause an error
83-
--> $DIR/const_panic.rs:30:20
83+
--> $DIR/const_panic.rs:31:20
8484
|
8585
LL | const X_CORE: () = core::unimplemented!();
8686
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
8787
| |
88-
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:30:20
88+
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:31:20
8989
|
9090
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
9191

9292
error: any use of this value will cause an error
93-
--> $DIR/const_panic.rs:33:20
93+
--> $DIR/const_panic.rs:34:20
9494
|
9595
LL | const W_CORE: () = core::panic!(MSG);
9696
| -------------------^^^^^^^^^^^^^^^^^-
9797
| |
98-
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:33:20
98+
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:34:20
9999
|
100100
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
101101

src/test/ui/drop/dynamic-drop-async.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl Allocator {
8282
self.cur_ops.set(self.cur_ops.get() + 1);
8383

8484
if self.cur_ops.get() == self.failing_op {
85-
panic!(InjectedFailure);
85+
panic::panic_any(InjectedFailure);
8686
}
8787
}
8888
}

src/test/ui/drop/dynamic-drop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Allocator {
4646
self.cur_ops.set(self.cur_ops.get() + 1);
4747

4848
if self.cur_ops.get() == self.failing_op {
49-
panic!(InjectedFailure);
49+
panic::panic_any(InjectedFailure);
5050
}
5151

5252
let mut data = self.data.borrow_mut();
@@ -67,7 +67,7 @@ impl<'a> Drop for Ptr<'a> {
6767
self.1.cur_ops.set(self.1.cur_ops.get() + 1);
6868

6969
if self.1.cur_ops.get() == self.1.failing_op {
70-
panic!(InjectedFailure);
70+
panic::panic_any(InjectedFailure);
7171
}
7272
}
7373
}

src/test/ui/macros/assert-macro-owned.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// error-pattern:panicked at 'test-assert-owned'
33
// ignore-emscripten no processes
44

5+
#![allow(non_fmt_panic)]
6+
57
fn main() {
68
assert!(false, "test-assert-owned".to_string());
79
}

src/test/ui/mir/mir_drop_order.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn main() {
3838
assert_eq!(get(), vec![0, 2, 3, 1]);
3939

4040
let _ = std::panic::catch_unwind(|| {
41-
(d(4), &d(5), d(6), &d(7), panic!(InjectedFailure));
41+
(d(4), &d(5), d(6), &d(7), panic::panic_any(InjectedFailure));
4242
});
4343

4444
// here, the temporaries (5/7) live until the end of the

src/test/ui/panics/explicit-panic-msg.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![allow(unused_assignments)]
22
#![allow(unused_variables)]
3+
#![allow(non_fmt_panic)]
34

45
// run-fail
56
// error-pattern:wooooo

src/test/ui/panics/panic-macro-any-wrapped.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// error-pattern:panicked at 'Box<Any>'
33
// ignore-emscripten no processes
44

5+
#![allow(non_fmt_panic)]
6+
57
fn main() {
68
panic!(Box::new(612_i64));
79
}

src/test/ui/panics/panic-macro-any.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// ignore-emscripten no processes
44

55
#![feature(box_syntax)]
6+
#![allow(non_fmt_panic)]
67

78
fn main() {
89
panic!(box 413 as Box<dyn std::any::Any + Send>);

src/test/ui/panics/while-panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// ignore-emscripten no processes
66

77
fn main() {
8-
panic!({
8+
panic!("{}", {
99
while true {
1010
panic!("giraffe")
1111
}

0 commit comments

Comments
 (0)