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