@@ -43,14 +43,22 @@ fn main() {
4343 1u32 as i32 ;
4444 1u64 as i64 ;
4545 1usize as isize ;
46- 1usize as i8 ; // should not wrap, usize is never 8 bits
47- 1usize as i16 ; // wraps on 16 bit ptr size
48- 1usize as i32 ; // wraps on 32 bit ptr size
49- 1usize as i64 ; // wraps on 64 bit ptr size
50- 1u8 as isize ; // should not wrap, isize is never 8 bits
51- 1u16 as isize ; // wraps on 16 bit ptr size
52- 1u32 as isize ; // wraps on 32 bit ptr size
53- 1u64 as isize ; // wraps on 64 bit ptr size
46+ // should not wrap, usize is never 8 bits
47+ 1usize as i8 ;
48+ // wraps on 16 bit ptr size
49+ 1usize as i16 ;
50+ // wraps on 32 bit ptr size
51+ 1usize as i32 ;
52+ // wraps on 64 bit ptr size
53+ 1usize as i64 ;
54+ // should not wrap, isize is never 8 bits
55+ 1u8 as isize ;
56+ // wraps on 16 bit ptr size
57+ 1u16 as isize ;
58+ // wraps on 32 bit ptr size
59+ 1u32 as isize ;
60+ // wraps on 64 bit ptr size
61+ 1u64 as isize ;
5462 // Test clippy::cast_sign_loss
5563 1i32 as u32 ;
5664 -1i32 as u32 ;
@@ -122,7 +130,8 @@ fn main() {
122130 let _ = s as i32 ;
123131
124132 // Test for signed min
125- ( -99999999999i64 ) . min ( 1 ) as i8 ; // should be linted because signed
133+ // should be linted because signed
134+ ( -99999999999i64 ) . min ( 1 ) as i8 ;
126135
127136 // Test for various operations that remove enough bits for the result to fit
128137 ( 999999u64 & 1 ) as u8 ;
@@ -134,7 +143,8 @@ fn main() {
134143 x. min ( 1 )
135144 } ) as u8 ;
136145 999999u64 . clamp ( 0 , 255 ) as u8 ;
137- 999999u64 . clamp ( 0 , 256 ) as u8 ; // should still be linted
146+ // should still be linted
147+ 999999u64 . clamp ( 0 , 256 ) as u8 ;
138148
139149 #[ derive( Clone , Copy ) ]
140150 enum E1 {
@@ -144,7 +154,8 @@ fn main() {
144154 }
145155 impl E1 {
146156 fn test ( self ) {
147- let _ = self as u8 ; // Don't lint. `0..=2` fits in u8
157+ // Don't lint. `0..=2` fits in u8
158+ let _ = self as u8 ;
148159 }
149160 }
150161
@@ -157,8 +168,10 @@ fn main() {
157168 fn test ( self ) {
158169 let _ = self as u8 ;
159170 let _ = Self :: B as u8 ;
160- let _ = self as i16 ; // Don't lint. `255..=256` fits in i16
161- let _ = Self :: A as u8 ; // Don't lint.
171+ // Don't lint. `255..=256` fits in i16
172+ let _ = self as i16 ;
173+ // Don't lint.
174+ let _ = Self :: A as u8 ;
162175 }
163176 }
164177
@@ -170,7 +183,8 @@ fn main() {
170183 }
171184 impl E3 {
172185 fn test ( self ) {
173- let _ = self as i8 ; // Don't lint. `-1..=50` fits in i8
186+ // Don't lint. `-1..=50` fits in i8
187+ let _ = self as i8 ;
174188 }
175189 }
176190
@@ -181,7 +195,8 @@ fn main() {
181195 }
182196 impl E4 {
183197 fn test ( self ) {
184- let _ = self as i8 ; // Don't lint. `-128..=-127` fits in i8
198+ // Don't lint. `-128..=-127` fits in i8
199+ let _ = self as i8 ;
185200 }
186201 }
187202
@@ -194,8 +209,10 @@ fn main() {
194209 fn test ( self ) {
195210 let _ = self as i8 ;
196211 let _ = Self :: A as i8 ;
197- let _ = self as i16 ; // Don't lint. `-129..=127` fits in i16
198- let _ = Self :: B as u8 ; // Don't lint.
212+ // Don't lint. `-129..=127` fits in i16
213+ let _ = self as i16 ;
214+ // Don't lint.
215+ let _ = Self :: B as u8 ;
199216 }
200217 }
201218
@@ -208,9 +225,12 @@ fn main() {
208225 impl E6 {
209226 fn test ( self ) {
210227 let _ = self as i16 ;
211- let _ = Self :: A as u16 ; // Don't lint. `2^16-1` fits in u16
212- let _ = self as u32 ; // Don't lint. `2^16-1..=2^16` fits in u32
213- let _ = Self :: A as u16 ; // Don't lint.
228+ // Don't lint. `2^16-1` fits in u16
229+ let _ = Self :: A as u16 ;
230+ // Don't lint. `2^16-1..=2^16` fits in u32
231+ let _ = self as u32 ;
232+ // Don't lint.
233+ let _ = Self :: A as u16 ;
214234 }
215235 }
216236
@@ -223,8 +243,10 @@ fn main() {
223243 impl E7 {
224244 fn test ( self ) {
225245 let _ = self as usize ;
226- let _ = Self :: A as usize ; // Don't lint.
227- let _ = self as u64 ; // Don't lint. `2^32-1..=2^32` fits in u64
246+ // Don't lint.
247+ let _ = Self :: A as usize ;
248+ // Don't lint. `2^32-1..=2^32` fits in u64
249+ let _ = self as u64 ;
228250 }
229251 }
230252
@@ -238,7 +260,8 @@ fn main() {
238260 }
239261 impl E8 {
240262 fn test ( self ) {
241- let _ = self as i128 ; // Don't lint. `-(2^127)..=2^127-1` fits it i128
263+ // Don't lint. `-(2^127)..=2^127-1` fits it i128
264+ let _ = self as i128 ;
242265 }
243266 }
244267
@@ -250,8 +273,10 @@ fn main() {
250273 }
251274 impl E9 {
252275 fn test ( self ) {
253- let _ = Self :: A as u8 ; // Don't lint.
254- let _ = self as u128 ; // Don't lint. `0..=2^128-1` fits in u128
276+ // Don't lint.
277+ let _ = Self :: A as u8 ;
278+ // Don't lint. `0..=2^128-1` fits in u128
279+ let _ = self as u128 ;
255280 }
256281 }
257282
@@ -264,8 +289,10 @@ fn main() {
264289 impl E10 {
265290 fn test ( self ) {
266291 let _ = self as u16 ;
267- let _ = Self :: B as u32 ; // Don't lint.
268- let _ = self as u64 ; // Don't lint.
292+ // Don't lint.
293+ let _ = Self :: B as u32 ;
294+ // Don't lint.
295+ let _ = self as u64 ;
269296 }
270297 }
271298}
0 commit comments