Test for empty blocks and update from master

This commit is contained in:
xFrednet 2021-03-05 19:23:12 +01:00
parent 8c0b4d7f65
commit 7c9e192e05
2 changed files with 39 additions and 28 deletions

View File

@ -99,6 +99,11 @@ fn valid_examples() {
let x = 2;
println!("{}", x);
}
// Let's test empty blocks
if false {
} else {
}
}
/// This makes sure that the `if_same_then_else` masks the `shared_code_in_if_blocks` lint
@ -128,20 +133,12 @@ fn trigger_other_lint() {
println!("I'm a doppelgänger");
// Don't listen to my clone below
if y == 90 {
"=^.^="
} else {
":D"
}
if y == 90 { "=^.^=" } else { ":D" }
} else {
// Don't listen to my clone above
println!("I'm a doppelgänger");
if y == 90 {
"=^.^="
} else {
":D"
}
if y == 90 { "=^.^=" } else { ":D" }
};
if x == 0 {

View File

@ -1,11 +1,8 @@
error: this `if` has identical blocks
--> $DIR/valid_if_blocks.rs:110:15
--> $DIR/valid_if_blocks.rs:104:14
|
LL | if x == 0 {
| _______________^
LL | | let u = 19;
LL | | println!("How are u today?");
LL | | let _ = "This is a string";
LL | if false {
| ______________^
LL | | } else {
| |_____^
|
@ -15,7 +12,26 @@ note: the lint level is defined here
LL | #![deny(clippy::if_same_then_else, clippy::shared_code_in_if_blocks)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: same as this
--> $DIR/valid_if_blocks.rs:114:12
--> $DIR/valid_if_blocks.rs:105:12
|
LL | } else {
| ____________^
LL | | }
| |_____^
error: this `if` has identical blocks
--> $DIR/valid_if_blocks.rs:115:15
|
LL | if x == 0 {
| _______________^
LL | | let u = 19;
LL | | println!("How are u today?");
LL | | let _ = "This is a string";
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/valid_if_blocks.rs:119:12
|
LL | } else {
| ____________^
@ -26,45 +42,43 @@ LL | | }
| |_____^
error: this `if` has identical blocks
--> $DIR/valid_if_blocks.rs:121:23
--> $DIR/valid_if_blocks.rs:126:23
|
LL | let _ = if x == 6 { 7 } else { 7 };
| ^^^^^
|
note: same as this
--> $DIR/valid_if_blocks.rs:121:34
--> $DIR/valid_if_blocks.rs:126:34
|
LL | let _ = if x == 6 { 7 } else { 7 };
| ^^^^^
error: this `if` has identical blocks
--> $DIR/valid_if_blocks.rs:127:23
--> $DIR/valid_if_blocks.rs:132:23
|
LL | } else if x == 68 {
| _______________________^
LL | | println!("I'm a doppelgänger");
LL | | // Don't listen to my clone below
LL | |
... |
LL | | }
LL | | if y == 90 { "=^.^=" } else { ":D" }
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/valid_if_blocks.rs:136:12
--> $DIR/valid_if_blocks.rs:137:12
|
LL | } else {
| ____________^
LL | | // Don't listen to my clone above
LL | | println!("I'm a doppelgänger");
LL | |
... |
LL | | }
LL | | if y == 90 { "=^.^=" } else { ":D" }
LL | | };
| |_____^
error: this `if` has identical blocks
--> $DIR/valid_if_blocks.rs:149:23
--> $DIR/valid_if_blocks.rs:146:23
|
LL | } else if x == 68 {
| _______________________^
@ -74,7 +88,7 @@ LL | | } else {
| |_____^
|
note: same as this
--> $DIR/valid_if_blocks.rs:152:12
--> $DIR/valid_if_blocks.rs:149:12
|
LL | } else {
| ____________^
@ -83,5 +97,5 @@ LL | | println!("I'm a doppelgänger");
LL | | }
| |_____^
error: aborting due to 4 previous errors
error: aborting due to 5 previous errors