]> git.lizzy.rs Git - rust.git/blob - tests/ui/panic.rs
iterate List by value
[rust.git] / tests / ui / panic.rs
1 #![warn(clippy::panic_params)]
2 #![allow(clippy::assertions_on_constants)]
3 fn missing() {
4     if true {
5         panic!("{}");
6     } else if false {
7         panic!("{:?}");
8     } else {
9         assert!(true, "here be missing values: {}");
10     }
11
12     panic!("{{{this}}}");
13 }
14
15 fn ok_single() {
16     panic!("foo bar");
17 }
18
19 fn ok_inner() {
20     // Test for #768
21     assert!("foo bar".contains(&format!("foo {}", "bar")));
22 }
23
24 fn ok_multiple() {
25     panic!("{}", "This is {ok}");
26 }
27
28 fn ok_bracket() {
29     match 42 {
30         1337 => panic!("{so is this"),
31         666 => panic!("so is this}"),
32         _ => panic!("}so is that{"),
33     }
34 }
35
36 const ONE: u32 = 1;
37
38 fn ok_nomsg() {
39     assert!({ 1 == ONE });
40     assert!(if 1 == ONE { ONE == 1 } else { false });
41 }
42
43 fn ok_escaped() {
44     panic!("{{ why should this not be ok? }}");
45     panic!(" or {{ that ?");
46     panic!(" or }} this ?");
47     panic!(" {or {{ that ?");
48     panic!(" }or }} this ?");
49     panic!("{{ test }");
50     panic!("{case }}");
51 }
52
53 fn main() {
54     missing();
55     ok_single();
56     ok_multiple();
57     ok_bracket();
58     ok_inner();
59     ok_nomsg();
60     ok_escaped();
61 }