summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unnecessary_cast.stderr
blob: d4786f66e4476d96293e35419562afcd88b70d1d (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`)
  --> $DIR/unnecessary_cast.rs:18:5
   |
LL |     ptr as *const T
   |     ^^^^^^^^^^^^^^^ help: try: `ptr`
   |
   = note: `-D clippy::unnecessary-cast` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]`

error: casting integer literal to `i32` is unnecessary
  --> $DIR/unnecessary_cast.rs:53:5
   |
LL |     1i32 as i32;
   |     ^^^^^^^^^^^ help: try: `1_i32`

error: casting float literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:54:5
   |
LL |     1f32 as f32;
   |     ^^^^^^^^^^^ help: try: `1_f32`

error: casting to the same type is unnecessary (`bool` -> `bool`)
  --> $DIR/unnecessary_cast.rs:55:5
   |
LL |     false as bool;
   |     ^^^^^^^^^^^^^ help: try: `false`

error: casting integer literal to `i32` is unnecessary
  --> $DIR/unnecessary_cast.rs:58:5
   |
LL |     -1_i32 as i32;
   |     ^^^^^^^^^^^^^ help: try: `-1_i32`

error: casting integer literal to `i32` is unnecessary
  --> $DIR/unnecessary_cast.rs:59:5
   |
LL |     - 1_i32 as i32;
   |     ^^^^^^^^^^^^^^ help: try: `- 1_i32`

error: casting float literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:60:5
   |
LL |     -1f32 as f32;
   |     ^^^^^^^^^^^^ help: try: `-1_f32`

error: casting integer literal to `i32` is unnecessary
  --> $DIR/unnecessary_cast.rs:61:5
   |
LL |     1_i32 as i32;
   |     ^^^^^^^^^^^^ help: try: `1_i32`

error: casting float literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:62:5
   |
LL |     1_f32 as f32;
   |     ^^^^^^^^^^^^ help: try: `1_f32`

error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`)
  --> $DIR/unnecessary_cast.rs:64:22
   |
LL |     let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8;
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()`

error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`)
  --> $DIR/unnecessary_cast.rs:66:5
   |
LL |     [1u8, 2].as_ptr() as *const u8;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()`

error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`)
  --> $DIR/unnecessary_cast.rs:68:5
   |
LL |     [1u8, 2].as_mut_ptr() as *mut u8;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_mut_ptr()`

error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`)
  --> $DIR/unnecessary_cast.rs:79:5
   |
LL |     owo::<u32>([1u32].as_ptr()) as *const u32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `owo::<u32>([1u32].as_ptr())`

error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`)
  --> $DIR/unnecessary_cast.rs:80:5
   |
LL |     uwu::<u32, u8>([1u32].as_ptr()) as *const u8;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::<u32, u8>([1u32].as_ptr())`

error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`)
  --> $DIR/unnecessary_cast.rs:82:5
   |
LL |     uwu::<u32, u32>([1u32].as_ptr()) as *const u32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::<u32, u32>([1u32].as_ptr())`

error: casting to the same type is unnecessary (`u32` -> `u32`)
  --> $DIR/unnecessary_cast.rs:117:5
   |
LL |     aaa() as u32;
   |     ^^^^^^^^^^^^ help: try: `aaa()`

error: casting to the same type is unnecessary (`u32` -> `u32`)
  --> $DIR/unnecessary_cast.rs:119:5
   |
LL |     aaa() as u32;
   |     ^^^^^^^^^^^^ help: try: `aaa()`

error: casting integer literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:155:9
   |
LL |         100 as f32;
   |         ^^^^^^^^^^ help: try: `100_f32`

error: casting integer literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:156:9
   |
LL |         100 as f64;
   |         ^^^^^^^^^^ help: try: `100_f64`

error: casting integer literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:157:9
   |
LL |         100_i32 as f64;
   |         ^^^^^^^^^^^^^^ help: try: `100_f64`

error: casting integer literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:158:17
   |
LL |         let _ = -100 as f32;
   |                 ^^^^^^^^^^^ help: try: `-100_f32`

error: casting integer literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:159:17
   |
LL |         let _ = -100 as f64;
   |                 ^^^^^^^^^^^ help: try: `-100_f64`

error: casting integer literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:160:17
   |
LL |         let _ = -100_i32 as f64;
   |                 ^^^^^^^^^^^^^^^ help: try: `-100_f64`

error: casting float literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:161:9
   |
LL |         100. as f32;
   |         ^^^^^^^^^^^ help: try: `100_f32`

error: casting float literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:162:9
   |
LL |         100. as f64;
   |         ^^^^^^^^^^^ help: try: `100_f64`

error: casting integer literal to `u32` is unnecessary
  --> $DIR/unnecessary_cast.rs:174:9
   |
LL |         1 as u32;
   |         ^^^^^^^^ help: try: `1_u32`

error: casting integer literal to `i32` is unnecessary
  --> $DIR/unnecessary_cast.rs:175:9
   |
LL |         0x10 as i32;
   |         ^^^^^^^^^^^ help: try: `0x10_i32`

error: casting integer literal to `usize` is unnecessary
  --> $DIR/unnecessary_cast.rs:176:9
   |
LL |         0b10 as usize;
   |         ^^^^^^^^^^^^^ help: try: `0b10_usize`

error: casting integer literal to `u16` is unnecessary
  --> $DIR/unnecessary_cast.rs:177:9
   |
LL |         0o73 as u16;
   |         ^^^^^^^^^^^ help: try: `0o73_u16`

error: casting integer literal to `u32` is unnecessary
  --> $DIR/unnecessary_cast.rs:178:9
   |
LL |         1_000_000_000 as u32;
   |         ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32`

error: casting float literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:180:9
   |
LL |         1.0 as f64;
   |         ^^^^^^^^^^ help: try: `1.0_f64`

error: casting float literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:181:9
   |
LL |         0.5 as f32;
   |         ^^^^^^^^^^ help: try: `0.5_f32`

error: casting integer literal to `i32` is unnecessary
  --> $DIR/unnecessary_cast.rs:185:17
   |
LL |         let _ = -1 as i32;
   |                 ^^^^^^^^^ help: try: `-1_i32`

error: casting float literal to `f32` is unnecessary
  --> $DIR/unnecessary_cast.rs:186:17
   |
LL |         let _ = -1.0 as f32;
   |                 ^^^^^^^^^^^ help: try: `-1.0_f32`

error: casting to the same type is unnecessary (`i32` -> `i32`)
  --> $DIR/unnecessary_cast.rs:192:18
   |
LL |         let _ = &(x as i32);
   |                  ^^^^^^^^^^ help: try: `{ x }`

error: casting integer literal to `i32` is unnecessary
  --> $DIR/unnecessary_cast.rs:198:22
   |
LL |         let _: i32 = -(1) as i32;
   |                      ^^^^^^^^^^^ help: try: `-1_i32`

error: casting integer literal to `i64` is unnecessary
  --> $DIR/unnecessary_cast.rs:200:22
   |
LL |         let _: i64 = -(1) as i64;
   |                      ^^^^^^^^^^^ help: try: `-1_i64`

error: casting float literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:207:22
   |
LL |         let _: f64 = (-8.0 as f64).exp();
   |                      ^^^^^^^^^^^^^ help: try: `(-8.0_f64)`

error: casting float literal to `f64` is unnecessary
  --> $DIR/unnecessary_cast.rs:209:23
   |
LL |         let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior
   |                       ^^^^^^^^^^^^ help: try: `8.0_f64`

error: casting to the same type is unnecessary (`f32` -> `f32`)
  --> $DIR/unnecessary_cast.rs:217:20
   |
LL |         let _num = foo() as f32;
   |                    ^^^^^^^^^^^^ help: try: `foo()`

error: aborting due to 40 previous errors