]> git.lizzy.rs Git - rust.git/blob - tests/ui/panic_unimplemented.rs
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / panic_unimplemented.rs
1 #![warn(clippy::panic_params, clippy::unimplemented)]
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 unimplemented() {
54     let a = 2;
55     unimplemented!();
56     let b = a + 2;
57 }
58
59 fn main() {
60     missing();
61     ok_single();
62     ok_multiple();
63     ok_bracket();
64     ok_inner();
65     ok_nomsg();
66     ok_escaped();
67     unimplemented();
68 }