2021-02-23 14:16:19 -06:00
|
|
|
error: all if blocks contain the same code at the start
|
2021-01-16 13:37:50 -06:00
|
|
|
--> $DIR/shared_at_top.rs:10:5
|
|
|
|
|
|
|
|
|
LL | / if true {
|
|
|
|
LL | | println!("Hello World!");
|
|
|
|
| |_________________________________^
|
|
|
|
|
|
|
|
|
note: the lint level is defined here
|
|
|
|
--> $DIR/shared_at_top.rs:2:36
|
|
|
|
|
|
2021-04-01 11:30:47 -05:00
|
|
|
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2021-02-23 14:16:19 -06:00
|
|
|
help: consider moving the start statements out like this
|
2021-01-16 13:37:50 -06:00
|
|
|
|
|
|
|
|
LL | println!("Hello World!");
|
|
|
|
LL | if true {
|
|
|
|
|
|
|
|
|
|
2021-02-23 14:16:19 -06:00
|
|
|
error: all if blocks contain the same code at the start
|
2021-01-16 13:37:50 -06:00
|
|
|
--> $DIR/shared_at_top.rs:19:5
|
|
|
|
|
|
|
|
|
LL | / if x == 0 {
|
|
|
|
LL | | let y = 9;
|
|
|
|
LL | | println!("The value y was set to: `{}`", y);
|
|
|
|
LL | | let _z = y;
|
|
|
|
| |___________________^
|
|
|
|
|
|
2021-02-25 16:33:46 -06:00
|
|
|
= warning: Some moved values might need to be renamed to avoid wrong references
|
2021-02-23 14:16:19 -06:00
|
|
|
help: consider moving the start statements out like this
|
2021-01-16 13:37:50 -06:00
|
|
|
|
|
|
|
|
LL | let y = 9;
|
|
|
|
LL | println!("The value y was set to: `{}`", y);
|
|
|
|
LL | let _z = y;
|
|
|
|
LL | if x == 0 {
|
|
|
|
|
|
|
|
|
|
2021-02-23 14:16:19 -06:00
|
|
|
error: all if blocks contain the same code at the start
|
2021-01-16 13:37:50 -06:00
|
|
|
--> $DIR/shared_at_top.rs:40:5
|
|
|
|
|
|
|
|
|
LL | / let _ = if x == 7 {
|
|
|
|
LL | | let y = 16;
|
|
|
|
| |___________________^
|
|
|
|
|
|
2021-02-23 14:16:19 -06:00
|
|
|
help: consider moving the start statements out like this
|
2021-01-16 13:37:50 -06:00
|
|
|
|
|
|
|
|
LL | let y = 16;
|
|
|
|
LL | let _ = if x == 7 {
|
|
|
|
|
|
|
|
|
|
2021-02-23 14:16:19 -06:00
|
|
|
error: all if blocks contain the same code at the start
|
2021-01-16 13:37:50 -06:00
|
|
|
--> $DIR/shared_at_top.rs:58:5
|
|
|
|
|
|
|
|
|
LL | / if x == 10 {
|
|
|
|
LL | | let used_value_name = "Different type";
|
|
|
|
LL | | println!("Str: {}", used_value_name);
|
|
|
|
| |_____________________________________________^
|
|
|
|
|
|
2021-02-25 16:33:46 -06:00
|
|
|
= warning: Some moved values might need to be renamed to avoid wrong references
|
2021-02-23 14:16:19 -06:00
|
|
|
help: consider moving the start statements out like this
|
2021-01-16 13:37:50 -06:00
|
|
|
|
|
|
|
|
LL | let used_value_name = "Different type";
|
|
|
|
LL | println!("Str: {}", used_value_name);
|
|
|
|
LL | if x == 10 {
|
|
|
|
|
|
|
|
|
|
2021-02-23 14:16:19 -06:00
|
|
|
error: all if blocks contain the same code at the start
|
2021-01-16 13:37:50 -06:00
|
|
|
--> $DIR/shared_at_top.rs:72:5
|
|
|
|
|
|
|
|
|
LL | / if x == 11 {
|
|
|
|
LL | | let can_be_overridden = "Move me";
|
|
|
|
LL | | println!("I'm also moveable");
|
|
|
|
| |______________________________________^
|
|
|
|
|
|
2021-02-25 16:33:46 -06:00
|
|
|
= warning: Some moved values might need to be renamed to avoid wrong references
|
2021-02-23 14:16:19 -06:00
|
|
|
help: consider moving the start statements out like this
|
2021-01-16 13:37:50 -06:00
|
|
|
|
|
|
|
|
LL | let can_be_overridden = "Move me";
|
|
|
|
LL | println!("I'm also moveable");
|
|
|
|
LL | if x == 11 {
|
|
|
|
|
|
|
|
|
|
2021-02-23 14:16:19 -06:00
|
|
|
error: all if blocks contain the same code at the start
|
2021-01-16 14:04:47 -06:00
|
|
|
--> $DIR/shared_at_top.rs:88:5
|
|
|
|
|
|
|
|
|
LL | / if x == 2020 {
|
|
|
|
LL | | println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint.");
|
|
|
|
LL | | println!("Because `IF_SAME_THEN_ELSE` is allowed here");
|
|
|
|
| |________________________________________________________________^
|
|
|
|
|
|
2021-02-23 14:16:19 -06:00
|
|
|
help: consider moving the start statements out like this
|
2021-01-16 14:04:47 -06:00
|
|
|
|
|
|
|
|
LL | println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint.");
|
|
|
|
LL | println!("Because `IF_SAME_THEN_ELSE` is allowed here");
|
|
|
|
LL | if x == 2020 {
|
|
|
|
|
|
|
|
|
|
|
|
|
error: this `if` has identical blocks
|
|
|
|
--> $DIR/shared_at_top.rs:96:18
|
|
|
|
|
|
|
|
|
LL | if x == 2019 {
|
|
|
|
| __________________^
|
|
|
|
LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual");
|
|
|
|
LL | | } else {
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
note: the lint level is defined here
|
|
|
|
--> $DIR/shared_at_top.rs:2:9
|
|
|
|
|
|
2021-04-01 11:30:47 -05:00
|
|
|
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
|
2021-01-16 14:04:47 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
note: same as this
|
|
|
|
--> $DIR/shared_at_top.rs:98:12
|
|
|
|
|
|
|
|
|
LL | } else {
|
|
|
|
| ____________^
|
|
|
|
LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual");
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
error: aborting due to 7 previous errors
|
2021-01-16 13:37:50 -06:00
|
|
|
|