Skip to content

Commit fcd9fa9

Browse files
committed
Add tests for panic and [debug_]assert in Rust 2021.
1 parent afe5335 commit fcd9fa9

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

src/test/ui/rust-2021/panic.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// edition:2021
2+
3+
fn main() {
4+
debug_assert!(false, 123);
5+
//~^ ERROR must be a string literal
6+
assert!(false, 123);
7+
//~^ ERROR must be a string literal
8+
panic!(false, 123);
9+
//~^ ERROR must be a string literal
10+
11+
std::debug_assert!(false, 123);
12+
//~^ ERROR must be a string literal
13+
std::assert!(false, 123);
14+
//~^ ERROR must be a string literal
15+
std::panic!(false, 123);
16+
//~^ ERROR must be a string literal
17+
18+
core::debug_assert!(false, 123);
19+
//~^ ERROR must be a string literal
20+
core::assert!(false, 123);
21+
//~^ ERROR must be a string literal
22+
core::panic!(false, 123);
23+
//~^ ERROR must be a string literal
24+
}

src/test/ui/rust-2021/panic.stderr

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
error: format argument must be a string literal
2+
--> $DIR/panic.rs:4:26
3+
|
4+
LL | debug_assert!(false, 123);
5+
| ^^^
6+
|
7+
help: you might be missing a string literal to format with
8+
|
9+
LL | debug_assert!(false, "{}", 123);
10+
| +++++
11+
12+
error: format argument must be a string literal
13+
--> $DIR/panic.rs:6:20
14+
|
15+
LL | assert!(false, 123);
16+
| ^^^
17+
|
18+
help: you might be missing a string literal to format with
19+
|
20+
LL | assert!(false, "{}", 123);
21+
| +++++
22+
23+
error: format argument must be a string literal
24+
--> $DIR/panic.rs:8:12
25+
|
26+
LL | panic!(false, 123);
27+
| ^^^^^
28+
|
29+
help: you might be missing a string literal to format with
30+
|
31+
LL | panic!("{} {}", false, 123);
32+
| ++++++++
33+
34+
error: format argument must be a string literal
35+
--> $DIR/panic.rs:11:31
36+
|
37+
LL | std::debug_assert!(false, 123);
38+
| ^^^
39+
|
40+
help: you might be missing a string literal to format with
41+
|
42+
LL | std::debug_assert!(false, "{}", 123);
43+
| +++++
44+
45+
error: format argument must be a string literal
46+
--> $DIR/panic.rs:13:25
47+
|
48+
LL | std::assert!(false, 123);
49+
| ^^^
50+
|
51+
help: you might be missing a string literal to format with
52+
|
53+
LL | std::assert!(false, "{}", 123);
54+
| +++++
55+
56+
error: format argument must be a string literal
57+
--> $DIR/panic.rs:15:17
58+
|
59+
LL | std::panic!(false, 123);
60+
| ^^^^^
61+
|
62+
help: you might be missing a string literal to format with
63+
|
64+
LL | std::panic!("{} {}", false, 123);
65+
| ++++++++
66+
67+
error: format argument must be a string literal
68+
--> $DIR/panic.rs:18:32
69+
|
70+
LL | core::debug_assert!(false, 123);
71+
| ^^^
72+
|
73+
help: you might be missing a string literal to format with
74+
|
75+
LL | core::debug_assert!(false, "{}", 123);
76+
| +++++
77+
78+
error: format argument must be a string literal
79+
--> $DIR/panic.rs:20:26
80+
|
81+
LL | core::assert!(false, 123);
82+
| ^^^
83+
|
84+
help: you might be missing a string literal to format with
85+
|
86+
LL | core::assert!(false, "{}", 123);
87+
| +++++
88+
89+
error: format argument must be a string literal
90+
--> $DIR/panic.rs:22:18
91+
|
92+
LL | core::panic!(false, 123);
93+
| ^^^^^
94+
|
95+
help: you might be missing a string literal to format with
96+
|
97+
LL | core::panic!("{} {}", false, 123);
98+
| ++++++++
99+
100+
error: aborting due to 9 previous errors
101+

0 commit comments

Comments
 (0)