diff options
| author | xFrednet <xFrednet@gmail.com> | 2021-03-05 19:23:12 +0100 |
|---|---|---|
| committer | xFrednet <xFrednet@gmail.com> | 2021-04-05 13:35:51 +0200 |
| commit | 7c9e192e055f8b8a8a5f8b177c415440bc2333ce (patch) | |
| tree | 2a7014011dd894095f407bdc481c316477360e8a | |
| parent | 8c0b4d7f65802031f0131bc56de8fb8b275d70d7 (diff) | |
| download | rust-7c9e192e055f8b8a8a5f8b177c415440bc2333ce.tar.gz rust-7c9e192e055f8b8a8a5f8b177c415440bc2333ce.zip | |
Test for empty blocks and update from master
| -rw-r--r-- | tests/ui/shared_code_in_if_blocks/valid_if_blocks.rs | 17 | ||||
| -rw-r--r-- | tests/ui/shared_code_in_if_blocks/valid_if_blocks.stderr | 50 |
2 files changed, 39 insertions, 28 deletions
diff --git a/tests/ui/shared_code_in_if_blocks/valid_if_blocks.rs b/tests/ui/shared_code_in_if_blocks/valid_if_blocks.rs index cd397db47d0..e63490d5b07 100644 --- a/tests/ui/shared_code_in_if_blocks/valid_if_blocks.rs +++ b/tests/ui/shared_code_in_if_blocks/valid_if_blocks.rs @@ -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 { diff --git a/tests/ui/shared_code_in_if_blocks/valid_if_blocks.stderr b/tests/ui/shared_code_in_if_blocks/valid_if_blocks.stderr index 2061cc25d21..846581456dc 100644 --- a/tests/ui/shared_code_in_if_blocks/valid_if_blocks.stderr +++ b/tests/ui/shared_code_in_if_blocks/valid_if_blocks.stderr @@ -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 |
