let x = "hello";
let y = "world";
if x == "hello" {
-
-
-
if y == "world" {
println!("Hello world!");
}
}
if x == "hello" || x == "world" {
-
-
-
if y == "world" || y == "hello" {
println!("Hello world!");
}
}
if x == "hello" && x == "world" {
-
-
-
if y == "world" || y == "hello" {
println!("Hello world!");
}
}
if x == "hello" || x == "world" {
-
-
-
if y == "world" && y == "hello" {
println!("Hello world!");
}
}
if x == "hello" && x == "world" {
-
-
-
if y == "world" && y == "hello" {
println!("Hello world!");
}
}
if 42 == 1337 {
-
-
-
if 'a' != 'A' {
println!("world!")
}
if x == "hello" {
print!("Hello ");
} else {
-
-
-
if y == "world" {
println!("world!")
}
if x == "hello" {
print!("Hello ");
} else {
-
-
-
if let Some(42) = Some(42) {
println!("world!")
}
if x == "hello" {
print!("Hello ");
} else {
-
-
-
if y == "world" {
println!("world")
}
if x == "hello" {
print!("Hello ");
} else {
-
-
-
if let Some(42) = Some(42) {
println!("world")
}
if let Some(42) = Some(42) {
print!("Hello ");
} else {
-
-
-
if let Some(42) = Some(42) {
println!("world")
}
if let Some(42) = Some(42) {
print!("Hello ");
} else {
-
-
-
if x == "hello" {
println!("world")
}
if let Some(42) = Some(42) {
print!("Hello ");
} else {
-
-
-
if let Some(42) = Some(42) {
println!("world")
}
--> $DIR/collapsible_if.rs:8:5
|
8 | / if x == "hello" {
-9 | |
-10 | |
-11 | |
-... |
-14 | | }
-15 | | }
+9 | | if y == "world" {
+10 | | println!("Hello world!");
+11 | | }
+12 | | }
| |_____^
|
note: lint level defined here
| }
error: this if statement can be collapsed
- --> $DIR/collapsible_if.rs:17:5
+ --> $DIR/collapsible_if.rs:14:5
|
-17 | / if x == "hello" || x == "world" {
-18 | |
-19 | |
-20 | |
-... |
-23 | | }
-24 | | }
+14 | / if x == "hello" || x == "world" {
+15 | | if y == "world" || y == "hello" {
+16 | | println!("Hello world!");
+17 | | }
+18 | | }
| |_____^
|
help: try
| }
error: this if statement can be collapsed
- --> $DIR/collapsible_if.rs:26:5
+ --> $DIR/collapsible_if.rs:20:5
|
-26 | / if x == "hello" && x == "world" {
-27 | |
-28 | |
-29 | |
-... |
-32 | | }
-33 | | }
+20 | / if x == "hello" && x == "world" {
+21 | | if y == "world" || y == "hello" {
+22 | | println!("Hello world!");
+23 | | }
+24 | | }
| |_____^
|
help: try
| }
error: this if statement can be collapsed
- --> $DIR/collapsible_if.rs:35:5
+ --> $DIR/collapsible_if.rs:26:5
|
-35 | / if x == "hello" || x == "world" {
-36 | |
-37 | |
-38 | |
-... |
-41 | | }
-42 | | }
+26 | / if x == "hello" || x == "world" {
+27 | | if y == "world" && y == "hello" {
+28 | | println!("Hello world!");
+29 | | }
+30 | | }
| |_____^
|
help: try
| }
error: this if statement can be collapsed
- --> $DIR/collapsible_if.rs:44:5
+ --> $DIR/collapsible_if.rs:32:5
|
-44 | / if x == "hello" && x == "world" {
-45 | |
-46 | |
-47 | |
-... |
-50 | | }
-51 | | }
+32 | / if x == "hello" && x == "world" {
+33 | | if y == "world" && y == "hello" {
+34 | | println!("Hello world!");
+35 | | }
+36 | | }
| |_____^
|
help: try
| }
error: this if statement can be collapsed
- --> $DIR/collapsible_if.rs:53:5
+ --> $DIR/collapsible_if.rs:38:5
|
-53 | / if 42 == 1337 {
-54 | |
-55 | |
-56 | |
-... |
-59 | | }
-60 | | }
+38 | / if 42 == 1337 {
+39 | | if 'a' != 'A' {
+40 | | println!("world!")
+41 | | }
+42 | | }
| |_____^
|
help: try
| }
error: this `else { if .. }` block can be collapsed
- --> $DIR/collapsible_if.rs:65:12
+ --> $DIR/collapsible_if.rs:47:12
|
-65 | } else {
+47 | } else {
| ____________^
-66 | |
-67 | |
-68 | |
-... |
-71 | | }
-72 | | }
+48 | | if y == "world" {
+49 | | println!("world!")
+50 | | }
+51 | | }
| |_____^
|
help: try
| }
error: this `else { if .. }` block can be collapsed
- --> $DIR/collapsible_if.rs:76:12
+ --> $DIR/collapsible_if.rs:55:12
|
-76 | } else {
+55 | } else {
| ____________^
-77 | |
-78 | |
-79 | |
-... |
-82 | | }
-83 | | }
+56 | | if let Some(42) = Some(42) {
+57 | | println!("world!")
+58 | | }
+59 | | }
| |_____^
|
help: try
| }
error: this `else { if .. }` block can be collapsed
- --> $DIR/collapsible_if.rs:87:12
+ --> $DIR/collapsible_if.rs:63:12
|
-87 | } else {
+63 | } else {
| ____________^
-88 | |
-89 | |
-90 | |
+64 | | if y == "world" {
+65 | | println!("world")
+66 | | }
... |
-96 | | }
-97 | | }
+69 | | }
+70 | | }
| |_____^
|
help: try
| }
error: this `else { if .. }` block can be collapsed
- --> $DIR/collapsible_if.rs:101:12
- |
-101 | } else {
- | ____________^
-102 | |
-103 | |
-104 | |
-... |
-110 | | }
-111 | | }
- | |_____^
- |
+ --> $DIR/collapsible_if.rs:74:12
+ |
+74 | } else {
+ | ____________^
+75 | | if let Some(42) = Some(42) {
+76 | | println!("world")
+77 | | }
+... |
+80 | | }
+81 | | }
+ | |_____^
+ |
help: try
- | } else if let Some(42) = Some(42) {
- | println!("world")
- | }
- | else {
- | println!("!")
- | }
+ | } 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 | | }
- | |_____^
- |
+ --> $DIR/collapsible_if.rs:85:12
+ |
+85 | } else {
+ | ____________^
+86 | | if let Some(42) = Some(42) {
+87 | | println!("world")
+88 | | }
+... |
+91 | | }
+92 | | }
+ | |_____^
+ |
help: try
- | } else if let Some(42) = Some(42) {
- | println!("world")
- | }
- | else {
- | println!("!")
- | }
+ | } 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
+ --> $DIR/collapsible_if.rs:96:12
|
-129 | } else {
+96 | } else {
| ____________^
-130 | |
-131 | |
-132 | |
+97 | | if x == "hello" {
+98 | | println!("world")
+99 | | }
... |
-138 | | }
-139 | | }
+102 | | }
+103 | | }
| |_____^
|
help: try
| }
error: this `else { if .. }` block can be collapsed
- --> $DIR/collapsible_if.rs:143:12
+ --> $DIR/collapsible_if.rs:107:12
|
-143 | } else {
+107 | } else {
| ____________^
-144 | |
-145 | |
-146 | |
+108 | | if let Some(42) = Some(42) {
+109 | | println!("world")
+110 | | }
... |
-152 | | }
-153 | | }
+113 | | }
+114 | | }
| |_____^
|
help: try