11error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`)
2- --> tests/ui/unnecessary_cast.rs:19 :5
2+ --> tests/ui/unnecessary_cast.rs:20 :5
33 |
44LL | ptr as *const T
55 | ^^^^^^^^^^^^^^^ help: try: `ptr`
@@ -8,244 +8,256 @@ LL | ptr as *const T
88 = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]`
99
1010error: casting integer literal to `i32` is unnecessary
11- --> tests/ui/unnecessary_cast.rs:55 :5
11+ --> tests/ui/unnecessary_cast.rs:56 :5
1212 |
1313LL | 1i32 as i32;
1414 | ^^^^^^^^^^^ help: try: `1_i32`
1515
1616error: casting float literal to `f32` is unnecessary
17- --> tests/ui/unnecessary_cast.rs:57 :5
17+ --> tests/ui/unnecessary_cast.rs:58 :5
1818 |
1919LL | 1f32 as f32;
2020 | ^^^^^^^^^^^ help: try: `1_f32`
2121
2222error: casting to the same type is unnecessary (`bool` -> `bool`)
23- --> tests/ui/unnecessary_cast.rs:59 :5
23+ --> tests/ui/unnecessary_cast.rs:60 :5
2424 |
2525LL | false as bool;
2626 | ^^^^^^^^^^^^^ help: try: `false`
2727
2828error: casting integer literal to `i32` is unnecessary
29- --> tests/ui/unnecessary_cast.rs:63 :5
29+ --> tests/ui/unnecessary_cast.rs:64 :5
3030 |
3131LL | -1_i32 as i32;
3232 | ^^^^^^^^^^^^^ help: try: `-1_i32`
3333
3434error: casting integer literal to `i32` is unnecessary
35- --> tests/ui/unnecessary_cast.rs:65 :5
35+ --> tests/ui/unnecessary_cast.rs:66 :5
3636 |
3737LL | - 1_i32 as i32;
3838 | ^^^^^^^^^^^^^^ help: try: `- 1_i32`
3939
4040error: casting float literal to `f32` is unnecessary
41- --> tests/ui/unnecessary_cast.rs:67 :5
41+ --> tests/ui/unnecessary_cast.rs:68 :5
4242 |
4343LL | -1f32 as f32;
4444 | ^^^^^^^^^^^^ help: try: `-1_f32`
4545
4646error: casting integer literal to `i32` is unnecessary
47- --> tests/ui/unnecessary_cast.rs:69 :5
47+ --> tests/ui/unnecessary_cast.rs:70 :5
4848 |
4949LL | 1_i32 as i32;
5050 | ^^^^^^^^^^^^ help: try: `1_i32`
5151
5252error: casting float literal to `f32` is unnecessary
53- --> tests/ui/unnecessary_cast.rs:71 :5
53+ --> tests/ui/unnecessary_cast.rs:72 :5
5454 |
5555LL | 1_f32 as f32;
5656 | ^^^^^^^^^^^^ help: try: `1_f32`
5757
5858error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`)
59- --> tests/ui/unnecessary_cast.rs:74 :22
59+ --> tests/ui/unnecessary_cast.rs:75 :22
6060 |
6161LL | let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8;
6262 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()`
6363
6464error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`)
65- --> tests/ui/unnecessary_cast.rs:77 :5
65+ --> tests/ui/unnecessary_cast.rs:78 :5
6666 |
6767LL | [1u8, 2].as_ptr() as *const u8;
6868 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()`
6969
7070error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`)
71- --> tests/ui/unnecessary_cast.rs:80 :5
71+ --> tests/ui/unnecessary_cast.rs:81 :5
7272 |
7373LL | [1u8, 2].as_mut_ptr() as *mut u8;
7474 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_mut_ptr()`
7575
7676error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`)
77- --> tests/ui/unnecessary_cast.rs:92 :5
77+ --> tests/ui/unnecessary_cast.rs:93 :5
7878 |
7979LL | owo::<u32>([1u32].as_ptr()) as *const u32;
8080 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `owo::<u32>([1u32].as_ptr())`
8181
8282error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`)
83- --> tests/ui/unnecessary_cast.rs:94 :5
83+ --> tests/ui/unnecessary_cast.rs:95 :5
8484 |
8585LL | uwu::<u32, u8>([1u32].as_ptr()) as *const u8;
8686 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::<u32, u8>([1u32].as_ptr())`
8787
8888error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`)
89- --> tests/ui/unnecessary_cast.rs:97 :5
89+ --> tests/ui/unnecessary_cast.rs:98 :5
9090 |
9191LL | uwu::<u32, u32>([1u32].as_ptr()) as *const u32;
9292 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::<u32, u32>([1u32].as_ptr())`
9393
9494error: casting to the same type is unnecessary (`u32` -> `u32`)
95- --> tests/ui/unnecessary_cast.rs:133 :5
95+ --> tests/ui/unnecessary_cast.rs:134 :5
9696 |
9797LL | aaa() as u32;
9898 | ^^^^^^^^^^^^ help: try: `aaa()`
9999
100100error: casting to the same type is unnecessary (`u32` -> `u32`)
101- --> tests/ui/unnecessary_cast.rs:136 :5
101+ --> tests/ui/unnecessary_cast.rs:137 :5
102102 |
103103LL | aaa() as u32;
104104 | ^^^^^^^^^^^^ help: try: `aaa()`
105105
106106error: casting integer literal to `f32` is unnecessary
107- --> tests/ui/unnecessary_cast.rs:173 :9
107+ --> tests/ui/unnecessary_cast.rs:174 :9
108108 |
109109LL | 100 as f32;
110110 | ^^^^^^^^^^ help: try: `100_f32`
111111
112112error: casting integer literal to `f64` is unnecessary
113- --> tests/ui/unnecessary_cast.rs:175 :9
113+ --> tests/ui/unnecessary_cast.rs:176 :9
114114 |
115115LL | 100 as f64;
116116 | ^^^^^^^^^^ help: try: `100_f64`
117117
118118error: casting integer literal to `f64` is unnecessary
119- --> tests/ui/unnecessary_cast.rs:177 :9
119+ --> tests/ui/unnecessary_cast.rs:178 :9
120120 |
121121LL | 100_i32 as f64;
122122 | ^^^^^^^^^^^^^^ help: try: `100_f64`
123123
124124error: casting integer literal to `f32` is unnecessary
125- --> tests/ui/unnecessary_cast.rs:179 :17
125+ --> tests/ui/unnecessary_cast.rs:180 :17
126126 |
127127LL | let _ = -100 as f32;
128128 | ^^^^^^^^^^^ help: try: `-100_f32`
129129
130130error: casting integer literal to `f64` is unnecessary
131- --> tests/ui/unnecessary_cast.rs:181 :17
131+ --> tests/ui/unnecessary_cast.rs:182 :17
132132 |
133133LL | let _ = -100 as f64;
134134 | ^^^^^^^^^^^ help: try: `-100_f64`
135135
136136error: casting integer literal to `f64` is unnecessary
137- --> tests/ui/unnecessary_cast.rs:183 :17
137+ --> tests/ui/unnecessary_cast.rs:184 :17
138138 |
139139LL | let _ = -100_i32 as f64;
140140 | ^^^^^^^^^^^^^^^ help: try: `-100_f64`
141141
142142error: casting float literal to `f32` is unnecessary
143- --> tests/ui/unnecessary_cast.rs:185 :9
143+ --> tests/ui/unnecessary_cast.rs:186 :9
144144 |
145145LL | 100. as f32;
146146 | ^^^^^^^^^^^ help: try: `100_f32`
147147
148148error: casting float literal to `f64` is unnecessary
149- --> tests/ui/unnecessary_cast.rs:187 :9
149+ --> tests/ui/unnecessary_cast.rs:188 :9
150150 |
151151LL | 100. as f64;
152152 | ^^^^^^^^^^^ help: try: `100_f64`
153153
154154error: casting integer literal to `u32` is unnecessary
155- --> tests/ui/unnecessary_cast.rs:200 :9
155+ --> tests/ui/unnecessary_cast.rs:201 :9
156156 |
157157LL | 1 as u32;
158158 | ^^^^^^^^ help: try: `1_u32`
159159
160160error: casting integer literal to `i32` is unnecessary
161- --> tests/ui/unnecessary_cast.rs:202 :9
161+ --> tests/ui/unnecessary_cast.rs:203 :9
162162 |
163163LL | 0x10 as i32;
164164 | ^^^^^^^^^^^ help: try: `0x10_i32`
165165
166166error: casting integer literal to `usize` is unnecessary
167- --> tests/ui/unnecessary_cast.rs:204 :9
167+ --> tests/ui/unnecessary_cast.rs:205 :9
168168 |
169169LL | 0b10 as usize;
170170 | ^^^^^^^^^^^^^ help: try: `0b10_usize`
171171
172172error: casting integer literal to `u16` is unnecessary
173- --> tests/ui/unnecessary_cast.rs:206 :9
173+ --> tests/ui/unnecessary_cast.rs:207 :9
174174 |
175175LL | 0o73 as u16;
176176 | ^^^^^^^^^^^ help: try: `0o73_u16`
177177
178178error: casting integer literal to `u32` is unnecessary
179- --> tests/ui/unnecessary_cast.rs:208 :9
179+ --> tests/ui/unnecessary_cast.rs:209 :9
180180 |
181181LL | 1_000_000_000 as u32;
182182 | ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32`
183183
184184error: casting float literal to `f64` is unnecessary
185- --> tests/ui/unnecessary_cast.rs:211 :9
185+ --> tests/ui/unnecessary_cast.rs:212 :9
186186 |
187187LL | 1.0 as f64;
188188 | ^^^^^^^^^^ help: try: `1.0_f64`
189189
190190error: casting float literal to `f32` is unnecessary
191- --> tests/ui/unnecessary_cast.rs:213 :9
191+ --> tests/ui/unnecessary_cast.rs:214 :9
192192 |
193193LL | 0.5 as f32;
194194 | ^^^^^^^^^^ help: try: `0.5_f32`
195195
196196error: casting integer literal to `i32` is unnecessary
197- --> tests/ui/unnecessary_cast.rs:218 :17
197+ --> tests/ui/unnecessary_cast.rs:219 :17
198198 |
199199LL | let _ = -1 as i32;
200200 | ^^^^^^^^^ help: try: `-1_i32`
201201
202202error: casting float literal to `f32` is unnecessary
203- --> tests/ui/unnecessary_cast.rs:220 :17
203+ --> tests/ui/unnecessary_cast.rs:221 :17
204204 |
205205LL | let _ = -1.0 as f32;
206206 | ^^^^^^^^^^^ help: try: `-1.0_f32`
207207
208208error: casting to the same type is unnecessary (`i32` -> `i32`)
209- --> tests/ui/unnecessary_cast.rs:227 :18
209+ --> tests/ui/unnecessary_cast.rs:228 :18
210210 |
211211LL | let _ = &(x as i32);
212212 | ^^^^^^^^^^ help: try: `{ x }`
213213
214214error: casting integer literal to `i32` is unnecessary
215- --> tests/ui/unnecessary_cast.rs:234 :22
215+ --> tests/ui/unnecessary_cast.rs:235 :22
216216 |
217217LL | let _: i32 = -(1) as i32;
218218 | ^^^^^^^^^^^ help: try: `-1_i32`
219219
220220error: casting integer literal to `i64` is unnecessary
221- --> tests/ui/unnecessary_cast.rs:237 :22
221+ --> tests/ui/unnecessary_cast.rs:238 :22
222222 |
223223LL | let _: i64 = -(1) as i64;
224224 | ^^^^^^^^^^^ help: try: `-1_i64`
225225
226226error: casting float literal to `f64` is unnecessary
227- --> tests/ui/unnecessary_cast.rs:245 :22
227+ --> tests/ui/unnecessary_cast.rs:246 :22
228228 |
229229LL | let _: f64 = (-8.0 as f64).exp();
230230 | ^^^^^^^^^^^^^ help: try: `(-8.0_f64)`
231231
232232error: casting float literal to `f64` is unnecessary
233- --> tests/ui/unnecessary_cast.rs:248 :23
233+ --> tests/ui/unnecessary_cast.rs:249 :23
234234 |
235235LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior
236236 | ^^^^^^^^^^^^ help: try: `8.0_f64`
237237
238238error: casting to the same type is unnecessary (`f32` -> `f32`)
239- --> tests/ui/unnecessary_cast.rs:258 :20
239+ --> tests/ui/unnecessary_cast.rs:259 :20
240240 |
241241LL | let _num = foo() as f32;
242242 | ^^^^^^^^^^^^ help: try: `foo()`
243243
244244error: casting to the same type is unnecessary (`usize` -> `usize`)
245- --> tests/ui/unnecessary_cast.rs:269 :9
245+ --> tests/ui/unnecessary_cast.rs:270 :9
246246 |
247247LL | (*x as usize).pow(2)
248248 | ^^^^^^^^^^^^^ help: try: `{ *x }`
249249
250- error: aborting due to 41 previous errors
250+ error: casting to the same type is unnecessary (`f64` -> `f64`)
251+ --> tests/ui/unnecessary_cast.rs:279:17
252+ |
253+ LL | let _ = (((1.0 / 8.0) as f64) as f64).powf(i as f64);
254+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `((1.0 / 8.0) as f64)`
255+
256+ error: casting to the same type is unnecessary (`u32` -> `u32`)
257+ --> tests/ui/unnecessary_cast.rs:290:11
258+ |
259+ LL | f((1 + 2u32) as u32);
260+ | ^^^^^^^^^^^^^^^^^ help: try: `(1 + 2u32)`
261+
262+ error: aborting due to 43 previous errors
251263
0 commit comments