summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr
blob: a270f637f2b91ea12e9dea65f68d5db93c774b71 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
error: all if blocks contain the same code at both the start and the end
  --> $DIR/shared_at_top_and_bottom.rs:16:5
   |
LL | /     if x == 7 {
LL | |         let t = 7;
LL | |         let _overlap_start = t * 2;
LL | |         let _overlap_end = 2 * t;
   | |_________________________________^
   |
note: the lint level is defined here
  --> $DIR/shared_at_top_and_bottom.rs:2:36
   |
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: this code is shared at the end
  --> $DIR/shared_at_top_and_bottom.rs:28:5
   |
LL | /         let _u = 9;
LL | |     }
   | |_____^
help: consider moving these statements before the if
   |
LL ~     let t = 7;
LL +     let _overlap_start = t * 2;
LL +     let _overlap_end = 2 * t;
LL +     if x == 7 {
   |
help: consider moving these statements after the if
   |
LL ~     }
LL +     let _u = 9;
   |

error: all if blocks contain the same code at both the start and the end
  --> $DIR/shared_at_top_and_bottom.rs:32:5
   |
LL | /     if x == 99 {
LL | |         let r = 7;
LL | |         let _overlap_start = r;
LL | |         let _overlap_middle = r * r;
   | |____________________________________^
   |
note: this code is shared at the end
  --> $DIR/shared_at_top_and_bottom.rs:43:5
   |
LL | /         let _overlap_end = r * r * r;
LL | |         let z = "end";
LL | |     }
   | |_____^
   = warning: some moved values might need to be renamed to avoid wrong references
help: consider moving these statements before the if
   |
LL ~     let r = 7;
LL +     let _overlap_start = r;
LL +     let _overlap_middle = r * r;
LL +     if x == 99 {
   |
help: consider moving these statements after the if
   |
LL ~     }
LL +     let _overlap_end = r * r * r;
LL +     let z = "end";
   |

error: all if blocks contain the same code at both the start and the end
  --> $DIR/shared_at_top_and_bottom.rs:61:5
   |
LL | /     if (x > 7 && y < 13) || (x + y) % 2 == 1 {
LL | |         let a = 0xcafe;
LL | |         let b = 0xffff00ff;
LL | |         let e_id = gen_id(a, b);
   | |________________________________^
   |
note: this code is shared at the end
  --> $DIR/shared_at_top_and_bottom.rs:81:5
   |
LL | /         let pack = DataPack {
LL | |             id: e_id,
LL | |             name: "Player 1".to_string(),
LL | |             some_data: vec![0x12, 0x34, 0x56, 0x78, 0x90],
LL | |         };
LL | |         process_data(pack);
LL | |     }
   | |_____^
   = warning: some moved values might need to be renamed to avoid wrong references
help: consider moving these statements before the if
   |
LL ~     let a = 0xcafe;
LL +     let b = 0xffff00ff;
LL +     let e_id = gen_id(a, b);
LL +     if (x > 7 && y < 13) || (x + y) % 2 == 1 {
   |
help: consider moving these statements after the if
   |
LL ~     }
LL +     let pack = DataPack {
LL +         id: e_id,
LL +         name: "Player 1".to_string(),
LL +         some_data: vec![0x12, 0x34, 0x56, 0x78, 0x90],
LL +     };
LL +     process_data(pack);
   |

error: all if blocks contain the same code at both the start and the end
  --> $DIR/shared_at_top_and_bottom.rs:94:5
   |
LL | /     let _ = if x == 7 {
LL | |         let _ = 19;
   | |___________________^
   |
note: this code is shared at the end
  --> $DIR/shared_at_top_and_bottom.rs:103:5
   |
LL | /         x << 2
LL | |     };
   | |_____^
   = note: the end suggestion probably needs some adjustments to use the expression result correctly
help: consider moving these statements before the if
   |
LL ~     let _ = 19;
LL +     let _ = if x == 7 {
   |
help: consider moving these statements after the if
   |
LL ~     }
LL ~     x << 2;
   |

error: all if blocks contain the same code at both the start and the end
  --> $DIR/shared_at_top_and_bottom.rs:106:5
   |
LL | /     if x == 9 {
LL | |         let _ = 17;
   | |___________________^
   |
note: this code is shared at the end
  --> $DIR/shared_at_top_and_bottom.rs:115:5
   |
LL | /         x * 4
LL | |     }
   | |_____^
   = note: the end suggestion probably needs some adjustments to use the expression result correctly
help: consider moving these statements before the if
   |
LL ~     let _ = 17;
LL +     if x == 9 {
   |
help: consider moving these statements after the if
   |
LL ~     }
LL +     x * 4
   |

error: aborting due to 5 previous errors