mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-01 00:49:30 +00:00
250 lines
4.3 KiB
Text
250 lines
4.3 KiB
Text
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:8:5
|
|
|
|
|
8 | / if x == "hello" {
|
|
9 | |
|
|
10 | |
|
|
11 | |
|
|
... |
|
|
14 | | }
|
|
15 | | }
|
|
| |_____^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/collapsible_if.rs:4:8
|
|
|
|
|
4 | #[deny(collapsible_if)]
|
|
| ^^^^^^^^^^^^^^
|
|
help: try
|
|
| if x == "hello" && y == "world" {
|
|
| println!("Hello world!");
|
|
| }
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:17:5
|
|
|
|
|
17 | / if x == "hello" || x == "world" {
|
|
18 | |
|
|
19 | |
|
|
20 | |
|
|
... |
|
|
23 | | }
|
|
24 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
|
|
| println!("Hello world!");
|
|
| }
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:26:5
|
|
|
|
|
26 | / if x == "hello" && x == "world" {
|
|
27 | |
|
|
28 | |
|
|
29 | |
|
|
... |
|
|
32 | | }
|
|
33 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| if x == "hello" && x == "world" && (y == "world" || y == "hello") {
|
|
| println!("Hello world!");
|
|
| }
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:35:5
|
|
|
|
|
35 | / if x == "hello" || x == "world" {
|
|
36 | |
|
|
37 | |
|
|
38 | |
|
|
... |
|
|
41 | | }
|
|
42 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| if (x == "hello" || x == "world") && y == "world" && y == "hello" {
|
|
| println!("Hello world!");
|
|
| }
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:44:5
|
|
|
|
|
44 | / if x == "hello" && x == "world" {
|
|
45 | |
|
|
46 | |
|
|
47 | |
|
|
... |
|
|
50 | | }
|
|
51 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| if x == "hello" && x == "world" && y == "world" && y == "hello" {
|
|
| println!("Hello world!");
|
|
| }
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:53:5
|
|
|
|
|
53 | / if 42 == 1337 {
|
|
54 | |
|
|
55 | |
|
|
56 | |
|
|
... |
|
|
59 | | }
|
|
60 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| if 42 == 1337 && 'a' != 'A' {
|
|
| println!("world!")
|
|
| }
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:65:12
|
|
|
|
|
65 | } else {
|
|
| ____________^
|
|
66 | |
|
|
67 | |
|
|
68 | |
|
|
... |
|
|
71 | | }
|
|
72 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| } else if y == "world" {
|
|
| println!("world!")
|
|
| }
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:76:12
|
|
|
|
|
76 | } else {
|
|
| ____________^
|
|
77 | |
|
|
78 | |
|
|
79 | |
|
|
... |
|
|
82 | | }
|
|
83 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| } else if let Some(42) = Some(42) {
|
|
| println!("world!")
|
|
| }
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:87:12
|
|
|
|
|
87 | } else {
|
|
| ____________^
|
|
88 | |
|
|
89 | |
|
|
90 | |
|
|
... |
|
|
96 | | }
|
|
97 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| } else if y == "world" {
|
|
| println!("world")
|
|
| }
|
|
| else {
|
|
| println!("!")
|
|
| }
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:101:12
|
|
|
|
|
101 | } else {
|
|
| ____________^
|
|
102 | |
|
|
103 | |
|
|
104 | |
|
|
... |
|
|
110 | | }
|
|
111 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| } else if let Some(42) = Some(42) {
|
|
| println!("world")
|
|
| }
|
|
| else {
|
|
| println!("!")
|
|
| }
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:115:12
|
|
|
|
|
115 | } else {
|
|
| ____________^
|
|
116 | |
|
|
117 | |
|
|
118 | |
|
|
... |
|
|
124 | | }
|
|
125 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| } else if let Some(42) = Some(42) {
|
|
| println!("world")
|
|
| }
|
|
| else {
|
|
| println!("!")
|
|
| }
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:129:12
|
|
|
|
|
129 | } else {
|
|
| ____________^
|
|
130 | |
|
|
131 | |
|
|
132 | |
|
|
... |
|
|
138 | | }
|
|
139 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| } else if x == "hello" {
|
|
| println!("world")
|
|
| }
|
|
| else {
|
|
| println!("!")
|
|
| }
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:143:12
|
|
|
|
|
143 | } else {
|
|
| ____________^
|
|
144 | |
|
|
145 | |
|
|
146 | |
|
|
... |
|
|
152 | | }
|
|
153 | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
| } else if let Some(42) = Some(42) {
|
|
| println!("world")
|
|
| }
|
|
| else {
|
|
| println!("!")
|
|
| }
|
|
|
|
error: aborting due to 13 previous errors
|
|
|