Skip to content

Commit c4e4641

Browse files
Remove/move comments to prevent weird rustfmt wrapping
1 parent 3c68f06 commit c4e4641

Some content is hidden

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

45 files changed

+819
-589
lines changed

tests/ui/bytecount.rs

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

7-
let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
7+
// naive byte count
8+
let _ = x.iter().filter(|&&a| a == 0).count();
89

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

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

13-
let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count(); // not a slice
16+
// not a slice
17+
let _ = x.iter().map(|a| a + 1).filter(|&a| a < 15).count();
1418

1519
let b = 0;
1620

17-
let _ = x.iter().filter(|_| b > 0).count(); // woah there
21+
// woah there
22+
let _ = x.iter().filter(|_| b > 0).count();
1823

19-
let _ = x.iter().filter(|_a| b == b + 1).count(); // nothing to see here, move along
24+
// nothing to see here, move along
25+
let _ = x.iter().filter(|_a| b == b + 1).count();
2026

21-
let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
27+
// naive byte count
28+
let _ = x.iter().filter(|a| b + 1 == **a).count();
2229

2330
let y = vec![0_u16; 3];
2431

25-
let _ = y.iter().filter(|&&a| a == 0).count(); // naive count, but not bytes
32+
// naive count, but not bytes
33+
let _ = y.iter().filter(|&&a| a == 0).count();
2634
}

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:7:13
2+
--> $DIR/bytecount.rs:8: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:9:13
14+
--> $DIR/bytecount.rs:11: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:21:13
20+
--> $DIR/bytecount.rs:28: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
@@ -41,14 +41,22 @@ fn main() {
4141
1u32 as i32;
4242
1u64 as i64;
4343
1usize as isize;
44-
1usize as i8; // should not wrap, usize is never 8 bits
45-
1usize as i16; // wraps on 16 bit ptr size
46-
1usize as i32; // wraps on 32 bit ptr size
47-
1usize as i64; // wraps on 64 bit ptr size
48-
1u8 as isize; // should not wrap, isize is never 8 bits
49-
1u16 as isize; // wraps on 16 bit ptr size
50-
1u32 as isize; // wraps on 32 bit ptr size
51-
1u64 as isize; // wraps on 64 bit ptr size
44+
// should not wrap, usize is never 8 bits
45+
1usize as i8;
46+
// wraps on 16 bit ptr size
47+
1usize as i16;
48+
// wraps on 32 bit ptr size
49+
1usize as i32;
50+
// wraps on 64 bit ptr size
51+
1usize as i64;
52+
// should not wrap, isize is never 8 bits
53+
1u8 as isize;
54+
// wraps on 16 bit ptr size
55+
1u16 as isize;
56+
// wraps on 32 bit ptr size
57+
1u32 as isize;
58+
// wraps on 64 bit ptr size
59+
1u64 as isize;
5260
// Test clippy::cast_sign_loss
5361
1i32 as u32;
5462
-1i32 as u32;
@@ -120,7 +128,8 @@ fn main() {
120128
let _ = s as i32;
121129

122130
// Test for signed min
123-
(-99999999999i64).min(1) as i8; // should be linted because signed
131+
// should be linted because signed
132+
(-99999999999i64).min(1) as i8;
124133

125134
// Test for various operations that remove enough bits for the result to fit
126135
(999999u64 & 1) as u8;
@@ -132,7 +141,8 @@ fn main() {
132141
x.min(1)
133142
}) as u8;
134143
999999u64.clamp(0, 255) as u8;
135-
999999u64.clamp(0, 256) as u8; // should still be linted
144+
// should still be linted
145+
999999u64.clamp(0, 256) as u8;
136146

137147
#[derive(Clone, Copy)]
138148
enum E1 {
@@ -142,7 +152,8 @@ fn main() {
142152
}
143153
impl E1 {
144154
fn test(self) {
145-
let _ = self as u8; // Don't lint. `0..=2` fits in u8
155+
// Don't lint. `0..=2` fits in u8
156+
let _ = self as u8;
146157
}
147158
}
148159

@@ -155,8 +166,10 @@ fn main() {
155166
fn test(self) {
156167
let _ = self as u8;
157168
let _ = Self::B as u8;
158-
let _ = self as i16; // Don't lint. `255..=256` fits in i16
159-
let _ = Self::A as u8; // Don't lint.
169+
// Don't lint. `255..=256` fits in i16
170+
let _ = self as i16;
171+
// Don't lint.
172+
let _ = Self::A as u8;
160173
}
161174
}
162175

@@ -168,7 +181,8 @@ fn main() {
168181
}
169182
impl E3 {
170183
fn test(self) {
171-
let _ = self as i8; // Don't lint. `-1..=50` fits in i8
184+
// Don't lint. `-1..=50` fits in i8
185+
let _ = self as i8;
172186
}
173187
}
174188

@@ -179,7 +193,8 @@ fn main() {
179193
}
180194
impl E4 {
181195
fn test(self) {
182-
let _ = self as i8; // Don't lint. `-128..=-127` fits in i8
196+
// Don't lint. `-128..=-127` fits in i8
197+
let _ = self as i8;
183198
}
184199
}
185200

@@ -192,8 +207,10 @@ fn main() {
192207
fn test(self) {
193208
let _ = self as i8;
194209
let _ = Self::A as i8;
195-
let _ = self as i16; // Don't lint. `-129..=127` fits in i16
196-
let _ = Self::B as u8; // Don't lint.
210+
// Don't lint. `-129..=127` fits in i16
211+
let _ = self as i16;
212+
// Don't lint.
213+
let _ = Self::B as u8;
197214
}
198215
}
199216

@@ -206,9 +223,12 @@ fn main() {
206223
impl E6 {
207224
fn test(self) {
208225
let _ = self as i16;
209-
let _ = Self::A as u16; // Don't lint. `2^16-1` fits in u16
210-
let _ = self as u32; // Don't lint. `2^16-1..=2^16` fits in u32
211-
let _ = Self::A as u16; // Don't lint.
226+
// Don't lint. `2^16-1` fits in u16
227+
let _ = Self::A as u16;
228+
// Don't lint. `2^16-1..=2^16` fits in u32
229+
let _ = self as u32;
230+
// Don't lint.
231+
let _ = Self::A as u16;
212232
}
213233
}
214234

@@ -221,8 +241,10 @@ fn main() {
221241
impl E7 {
222242
fn test(self) {
223243
let _ = self as usize;
224-
let _ = Self::A as usize; // Don't lint.
225-
let _ = self as u64; // Don't lint. `2^32-1..=2^32` fits in u64
244+
// Don't lint.
245+
let _ = Self::A as usize;
246+
// Don't lint. `2^32-1..=2^32` fits in u64
247+
let _ = self as u64;
226248
}
227249
}
228250

@@ -236,7 +258,8 @@ fn main() {
236258
}
237259
impl E8 {
238260
fn test(self) {
239-
let _ = self as i128; // Don't lint. `-(2^127)..=2^127-1` fits it i128
261+
// Don't lint. `-(2^127)..=2^127-1` fits it i128
262+
let _ = self as i128;
240263
}
241264
}
242265

@@ -248,8 +271,10 @@ fn main() {
248271
}
249272
impl E9 {
250273
fn test(self) {
251-
let _ = Self::A as u8; // Don't lint.
252-
let _ = self as u128; // Don't lint. `0..=2^128-1` fits in u128
274+
// Don't lint.
275+
let _ = Self::A as u8;
276+
// Don't lint. `0..=2^128-1` fits in u128
277+
let _ = self as u128;
253278
}
254279
}
255280

@@ -262,8 +287,10 @@ fn main() {
262287
impl E10 {
263288
fn test(self) {
264289
let _ = self as u16;
265-
let _ = Self::B as u32; // Don't lint.
266-
let _ = self as u64; // Don't lint.
290+
// Don't lint.
291+
let _ = Self::B as u32;
292+
// Don't lint.
293+
let _ = self as u64;
267294
}
268295
}
269296
}

0 commit comments

Comments
 (0)