]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/manual_assert.edition2018.fixed
26e3b8f63e700e2a53f579df14bbaf5ac5728452
[rust.git] / src / tools / clippy / tests / ui / manual_assert.edition2018.fixed
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     assert!(a.is_empty(), "qaqaq{:?}", a);
32     assert!(a.is_empty(), "qwqwq");
33     if a.len() == 3 {
34         println!("qwq");
35         println!("qwq");
36         println!("qwq");
37     }
38     if let Some(b) = c {
39         panic!("orz {}", b);
40     }
41     if a.len() == 3 {
42         panic!("qaqaq");
43     } else {
44         println!("qwq");
45     }
46     let b = vec![1, 2, 3];
47     assert!(!b.is_empty(), "panic1");
48     assert!(!(b.is_empty() && a.is_empty()), "panic2");
49     assert!(!(a.is_empty() && !b.is_empty()), "panic3");
50     assert!(!(b.is_empty() || a.is_empty()), "panic4");
51     assert!(!(a.is_empty() || !b.is_empty()), "panic5");
52     assert!(!a.is_empty(), "with expansion {}", one!());
53 }
54
55 fn issue7730(a: u8) {
56     // Suggestion should preserve comment
57     // comment
58 /* this is a
59         multiline
60         comment */
61 /// Doc comment
62 // comment after `panic!`
63 assert!(!(a > 2), "panic with comment");
64 }