blob: d890b12ecbb4c6d0b532ecb97e0254ce3bf1bebe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
error: all if blocks contain the same code at the start
--> $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
|
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider moving these statements before the if
|
LL ~ println!("Hello World!");
LL + if true {
|
error: all if blocks contain the same code at the start
--> $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;
| |___________________^
|
= warning: some moved values might need to be renamed to avoid wrong references
help: consider moving these statements before the if
|
LL ~ let y = 9;
LL + println!("The value y was set to: `{}`", y);
LL + let _z = y;
LL + if x == 0 {
|
error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:40:5
|
LL | / let _ = if x == 7 {
LL | | let y = 16;
| |___________________^
|
help: consider moving these statements before the if
|
LL ~ let y = 16;
LL + let _ = if x == 7 {
|
error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:58:5
|
LL | / if x == 10 {
LL | | let used_value_name = "Different type";
LL | | println!("Str: {}", used_value_name);
| |_____________________________________________^
|
= warning: some moved values might need to be renamed to avoid wrong references
help: consider moving these statements before the if
|
LL ~ let used_value_name = "Different type";
LL + println!("Str: {}", used_value_name);
LL + if x == 10 {
|
error: all if blocks contain the same code at the start
--> $DIR/shared_at_top.rs:72:5
|
LL | / if x == 11 {
LL | | let can_be_overridden = "Move me";
LL | | println!("I'm also moveable");
| |______________________________________^
|
= warning: some moved values might need to be renamed to avoid wrong references
help: consider moving these statements before the if
|
LL ~ let can_be_overridden = "Move me";
LL + println!("I'm also moveable");
LL + if x == 11 {
|
error: all if blocks contain the same code at the start
--> $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");
| |________________________________________________________________^
|
help: consider moving these statements before the if
|
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
|
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
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
|