]> git.lizzy.rs Git - rust.git/blob - tests/ui/manual_assert.rs
fallout: fix tests to allow uninlined_format_args
[rust.git] / tests / ui / manual_assert.rs
1 // revisions: edition2018 edition2021
2 // [edition2018] edition:2018
3 // [edition2021] edition:2021
4 // run-rustfix
5
6 #![warn(clippy::manual_assert)]
7 #![allow(dead_code, unused_doc_comments)]
8 #![allow(clippy::nonminimal_bool, clippy::uninlined_format_args)]
9
10 macro_rules! one {
11     () => {
12         1
13     };
14 }
15
16 fn main() {
17     let a = vec![1, 2, 3];
18     let c = Some(2);
19     if !a.is_empty()
20         && a.len() == 3
21         && c.is_some()
22         && !a.is_empty()
23         && a.len() == 3
24         && !a.is_empty()
25         && a.len() == 3
26         && !a.is_empty()
27         && a.len() == 3
28     {
29         panic!("qaqaq{:?}", a);
30     }
31     if !a.is_empty() {
32         panic!("qaqaq{:?}", a);
33     }
34     if !a.is_empty() {
35         panic!("qwqwq");
36     }
37     if a.len() == 3 {
38         println!("qwq");
39         println!("qwq");
40         println!("qwq");
41     }
42     if let Some(b) = c {
43         panic!("orz {}", b);
44     }
45     if a.len() == 3 {
46         panic!("qaqaq");
47     } else {
48         println!("qwq");
49     }
50     let b = vec![1, 2, 3];
51     if b.is_empty() {
52         panic!("panic1");
53     }
54     if b.is_empty() && a.is_empty() {
55         panic!("panic2");
56     }
57     if a.is_empty() && !b.is_empty() {
58         panic!("panic3");
59     }
60     if b.is_empty() || a.is_empty() {
61         panic!("panic4");
62     }
63     if a.is_empty() || !b.is_empty() {
64         panic!("panic5");
65     }
66     if a.is_empty() {
67         panic!("with expansion {}", one!())
68     }
69 }
70
71 fn issue7730(a: u8) {
72     // Suggestion should preserve comment
73     if a > 2 {
74         // comment
75         /* this is a
76         multiline
77         comment */
78         /// Doc comment
79         panic!("panic with comment") // comment after `panic!`
80     }
81 }