Skip to content

Commit 3a31c05

Browse files
Remove/move comments to prevent weird rustfmt wrapping
1 parent 9c96605 commit 3a31c05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+850
-607
lines changed

tests/ui/bytecount.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,31 @@
66
fn main() {
77
let x = vec![0_u8; 16];
88

9-
let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
9+
// naive byte count
10+
let _ = x.iter().filter(|&&a| a == 0).count();
1011

11-
let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
12+
// naive byte count
13+
let _ = (&x[..]).iter().filter(|&a| *a == 0).count();
1214

13-
let _ = x.iter().filter(|a| **a > 0).count(); // not an equality count, OK.
15+
// not an equality count, OK.
16+
let _ = x.iter().filter(|a| **a > 0).count();
1417

15-
let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count(); // not a slice
18+
// not a slice
19+
let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count();
1620

1721
let b = 0;
1822

19-
let _ = x.iter().filter(|_| b > 0).count(); // woah there
23+
// woah there
24+
let _ = x.iter().filter(|_| b > 0).count();
2025

21-
let _ = x.iter().filter(|_a| b == b + 1).count(); // nothing to see here, move along
26+
// nothing to see here, move along
27+
let _ = x.iter().filter(|_a| b == b + 1).count();
2228

23-
let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
29+
// naive byte count
30+
let _ = x.iter().filter(|a| b + 1 == **a).count();
2431

2532
let y = vec![0_u16; 3];
2633

27-
let _ = y.iter().filter(|&&a| a == 0).count(); // naive count, but not bytes
34+
// naive count, but not bytes
35+
let _ = y.iter().filter(|&&a| a == 0).count();
2836
}

tests/ui/bytecount.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: you appear to be counting bytes the naive way
2-
--> $DIR/bytecount.rs:9:13
2+
--> $DIR/bytecount.rs:10:13
33
|
4-
LL | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
4+
LL | let _ = x.iter().filter(|&&a| a == 0).count();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, 0)`
66
|
77
note: the lint level is defined here
@@ -11,15 +11,15 @@ LL | #[deny(clippy::naive_bytecount)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: you appear to be counting bytes the naive way
14-
--> $DIR/bytecount.rs:11:13
14+
--> $DIR/bytecount.rs:13:13
1515
|
16-
LL | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
16+
LL | let _ = (&x[..]).iter().filter(|&a| *a == 0).count();
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count((&x[..]), 0)`
1818

1919
error: you appear to be counting bytes the naive way
20-
--> $DIR/bytecount.rs:23:13
20+
--> $DIR/bytecount.rs:30:13
2121
|
22-
LL | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
22+
LL | let _ = x.iter().filter(|a| b + 1 == **a).count();
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, b + 1)`
2424

2525
error: aborting due to 3 previous errors

tests/ui/cast.rs

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)