38d4ac7cea
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
261 lines
5.4 KiB
Plaintext
261 lines
5.4 KiB
Plaintext
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:6:5
|
|
|
|
|
LL | / if x == "hello" {
|
|
LL | | if y == "world" {
|
|
LL | | println!("Hello world!");
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
= note: `-D clippy::collapsible-if` implied by `-D warnings`
|
|
help: try
|
|
|
|
|
LL | if x == "hello" && y == "world" {
|
|
LL | println!("Hello world!");
|
|
LL | }
|
|
|
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:12:5
|
|
|
|
|
LL | / if x == "hello" || x == "world" {
|
|
LL | | if y == "world" || y == "hello" {
|
|
LL | | println!("Hello world!");
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
|
|
LL | println!("Hello world!");
|
|
LL | }
|
|
|
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:18:5
|
|
|
|
|
LL | / if x == "hello" && x == "world" {
|
|
LL | | if y == "world" || y == "hello" {
|
|
LL | | println!("Hello world!");
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
|
|
LL | println!("Hello world!");
|
|
LL | }
|
|
|
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:24:5
|
|
|
|
|
LL | / if x == "hello" || x == "world" {
|
|
LL | | if y == "world" && y == "hello" {
|
|
LL | | println!("Hello world!");
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
|
|
LL | println!("Hello world!");
|
|
LL | }
|
|
|
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:30:5
|
|
|
|
|
LL | / if x == "hello" && x == "world" {
|
|
LL | | if y == "world" && y == "hello" {
|
|
LL | | println!("Hello world!");
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | if x == "hello" && x == "world" && y == "world" && y == "hello" {
|
|
LL | println!("Hello world!");
|
|
LL | }
|
|
|
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:36:5
|
|
|
|
|
LL | / if 42 == 1337 {
|
|
LL | | if 'a' != 'A' {
|
|
LL | | println!("world!")
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | if 42 == 1337 && 'a' != 'A' {
|
|
LL | println!("world!")
|
|
LL | }
|
|
|
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:45:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | if y == "world" {
|
|
LL | | println!("world!")
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | } else if y == "world" {
|
|
LL | println!("world!")
|
|
LL | }
|
|
|
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:53:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | if let Some(42) = Some(42) {
|
|
LL | | println!("world!")
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | } else if let Some(42) = Some(42) {
|
|
LL | println!("world!")
|
|
LL | }
|
|
|
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:61:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | if y == "world" {
|
|
LL | | println!("world")
|
|
LL | | }
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | } else if y == "world" {
|
|
LL | println!("world")
|
|
LL | }
|
|
LL | else {
|
|
LL | println!("!")
|
|
LL | }
|
|
|
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:72:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | if let Some(42) = Some(42) {
|
|
LL | | println!("world")
|
|
LL | | }
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | } else if let Some(42) = Some(42) {
|
|
LL | println!("world")
|
|
LL | }
|
|
LL | else {
|
|
LL | println!("!")
|
|
LL | }
|
|
|
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:83:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | if let Some(42) = Some(42) {
|
|
LL | | println!("world")
|
|
LL | | }
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | } else if let Some(42) = Some(42) {
|
|
LL | println!("world")
|
|
LL | }
|
|
LL | else {
|
|
LL | println!("!")
|
|
LL | }
|
|
|
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:94:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | if x == "hello" {
|
|
LL | | println!("world")
|
|
LL | | }
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | } else if x == "hello" {
|
|
LL | println!("world")
|
|
LL | }
|
|
LL | else {
|
|
LL | println!("!")
|
|
LL | }
|
|
|
|
|
|
|
error: this `else { if .. }` block can be collapsed
|
|
--> $DIR/collapsible_if.rs:105:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | if let Some(42) = Some(42) {
|
|
LL | | println!("world")
|
|
LL | | }
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | } else if let Some(42) = Some(42) {
|
|
LL | println!("world")
|
|
LL | }
|
|
LL | else {
|
|
LL | println!("!")
|
|
LL | }
|
|
|
|
|
|
|
error: this if statement can be collapsed
|
|
--> $DIR/collapsible_if.rs:164:5
|
|
|
|
|
LL | / if x == "hello" {
|
|
LL | | if y == "world" { // Collapsible
|
|
LL | | println!("Hello world!");
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
LL | if x == "hello" && y == "world" { // Collapsible
|
|
LL | println!("Hello world!");
|
|
LL | }
|
|
|
|
|
|
|
error: aborting due to 14 previous errors
|
|
|