]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/manual_assert.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / src / tools / clippy / 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 if a.is_empty() {
70 let _ = 0;
71 } else if a.len() == 1 {
72 panic!("panic6");
73 }
74 }
75
76 fn issue7730(a: u8) {
77 // Suggestion should preserve comment
78 if a > 2 {
79 // comment
80 /* this is a
81 multiline
82 comment */
83 /// Doc comment
84 panic!("panic with comment") // comment after `panic!`
85 }
86 }