2021-04-08 10:50:13 -05:00
|
|
|
error: all if blocks contain the same code at the start
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:11:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / if true {
|
|
|
|
LL | | println!("Hello World!");
|
|
|
|
| |_________________________________^
|
|
|
|
|
|
|
|
|
note: the lint level is defined here
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:1:9
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
2022-10-06 02:44:38 -05:00
|
|
|
LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)]
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2022-06-16 10:39:06 -05:00
|
|
|
help: consider moving these statements before the if
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ println!("Hello World!");
|
|
|
|
LL + if true {
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: all if blocks contain the same code at the start
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:21:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / if x == 0 {
|
|
|
|
LL | | let y = 9;
|
|
|
|
LL | | println!("The value y was set to: `{}`", y);
|
|
|
|
LL | | let _z = y;
|
|
|
|
| |___________________^
|
|
|
|
|
|
2022-06-16 10:39:06 -05:00
|
|
|
= warning: some moved values might need to be renamed to avoid wrong references
|
|
|
|
help: consider moving these statements before the if
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let y = 9;
|
|
|
|
LL + println!("The value y was set to: `{}`", y);
|
|
|
|
LL + let _z = y;
|
|
|
|
LL + if x == 0 {
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: all if blocks contain the same code at the start
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:43:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / let _ = if x == 7 {
|
2023-08-24 14:32:12 -05:00
|
|
|
LL | |
|
2021-04-08 10:50:13 -05:00
|
|
|
LL | | let y = 16;
|
|
|
|
| |___________________^
|
|
|
|
|
|
2022-06-16 10:39:06 -05:00
|
|
|
help: consider moving these statements before the if
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let y = 16;
|
|
|
|
LL + let _ = if x == 7 {
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: all if blocks contain the same code at the start
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:62:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / if x == 10 {
|
|
|
|
LL | | let used_value_name = "Different type";
|
|
|
|
LL | | println!("Str: {}", used_value_name);
|
|
|
|
| |_____________________________________________^
|
|
|
|
|
|
2022-06-16 10:39:06 -05:00
|
|
|
= warning: some moved values might need to be renamed to avoid wrong references
|
|
|
|
help: consider moving these statements before the if
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let used_value_name = "Different type";
|
|
|
|
LL + println!("Str: {}", used_value_name);
|
|
|
|
LL + if x == 10 {
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: all if blocks contain the same code at the start
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:77:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / if x == 11 {
|
2023-08-24 14:32:12 -05:00
|
|
|
LL | |
|
2021-04-08 10:50:13 -05:00
|
|
|
LL | | let can_be_overridden = "Move me";
|
|
|
|
LL | | println!("I'm also moveable");
|
|
|
|
| |______________________________________^
|
|
|
|
|
|
2022-06-16 10:39:06 -05:00
|
|
|
= warning: some moved values might need to be renamed to avoid wrong references
|
|
|
|
help: consider moving these statements before the if
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let can_be_overridden = "Move me";
|
|
|
|
LL + println!("I'm also moveable");
|
|
|
|
LL + if x == 11 {
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: all if blocks contain the same code at the start
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:94:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / if x == 2020 {
|
2023-08-24 14:32:12 -05:00
|
|
|
LL | |
|
2021-04-08 10:50:13 -05:00
|
|
|
LL | | println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint.");
|
|
|
|
LL | | println!("Because `IF_SAME_THEN_ELSE` is allowed here");
|
|
|
|
| |________________________________________________________________^
|
|
|
|
|
|
2022-06-16 10:39:06 -05:00
|
|
|
help: consider moving these statements before the if
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05: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 {
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: this `if` has identical blocks
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:103:18
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | if x == 2019 {
|
|
|
|
| __________________^
|
|
|
|
LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual");
|
|
|
|
LL | | } else {
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
note: same as this
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:105:12
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | } else {
|
|
|
|
| ____________^
|
|
|
|
LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual");
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
2022-09-22 11:04:22 -05:00
|
|
|
note: the lint level is defined here
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/branches_sharing_code/shared_at_top.rs:1:40
|
2022-09-22 11:04:22 -05:00
|
|
|
|
|
2022-10-06 02:44:38 -05:00
|
|
|
LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)]
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
error: aborting due to 7 previous errors
|
|
|
|
|