Skip to content

Commit 64aae82

Browse files
committed
Moved unfixable tests to separate file because ui_test otherwise would fail
1 parent 43a7a72 commit 64aae82

File tree

4 files changed

+43
-32
lines changed

4 files changed

+43
-32
lines changed

tests/ui/chunks_exact_with_const_size.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,4 @@ fn main() {
3636
.collect::<Vec<_>>()
3737
.chunks_exact(2);
3838
//~^ chunks_exact_with_const_size
39-
40-
// Should trigger lint with help message only (not suggestion) - stored in variable
41-
let mut chunk_iter = slice.chunks_exact(CHUNK_SIZE);
42-
//~^ chunks_exact_with_const_size
43-
for chunk in chunk_iter.by_ref() {}
44-
let _remainder = chunk_iter.remainder();
45-
46-
// Similar for mutable version - help message only
47-
let mut arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
48-
let mut chunk_iter = arr2.chunks_exact_mut(CHUNK_SIZE);
49-
//~^ chunks_exact_with_const_size
50-
for chunk in chunk_iter.by_ref() {}
51-
let _remainder = chunk_iter.into_remainder();
5239
}

tests/ui/chunks_exact_with_const_size.stderr

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,5 @@ LL | .chunks_exact(2);
4545
= help: consider using `as_chunks::<2>()` instead
4646
= note: you can access the chunks using `result.0.iter()`, and the remainder using `result.1`
4747

48-
error: using `chunks_exact` with a constant chunk size
49-
--> tests/ui/chunks_exact_with_const_size.rs:41:32
50-
|
51-
LL | let mut chunk_iter = slice.chunks_exact(CHUNK_SIZE);
52-
| ^^^^^^^^^^^^^^^^^^^^^^^^
53-
|
54-
= help: consider using `as_chunks::<CHUNK_SIZE>()` instead
55-
= note: you can access the chunks using `chunk_iter.0.iter()`, and the remainder using `chunk_iter.1`
56-
57-
error: using `chunks_exact_mut` with a constant chunk size
58-
--> tests/ui/chunks_exact_with_const_size.rs:48:31
59-
|
60-
LL | let mut chunk_iter = arr2.chunks_exact_mut(CHUNK_SIZE);
61-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62-
|
63-
= help: consider using `as_chunks_mut::<CHUNK_SIZE>()` instead
64-
= note: you can access the chunks using `chunk_iter.0.iter()`, and the remainder using `chunk_iter.1`
65-
66-
error: aborting due to 7 previous errors
48+
error: aborting due to 5 previous errors
6749

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![warn(clippy::chunks_exact_with_const_size)]
2+
#![allow(unused)]
3+
4+
fn main() {
5+
let slice = [1, 2, 3, 4, 5, 6, 7, 8];
6+
const CHUNK_SIZE: usize = 4;
7+
8+
// Should trigger lint with help message only (not suggestion) - stored in variable
9+
let mut chunk_iter = slice.chunks_exact(CHUNK_SIZE);
10+
//~^ chunks_exact_with_const_size
11+
for chunk in chunk_iter.by_ref() {}
12+
let _remainder = chunk_iter.remainder();
13+
14+
// Similar for mutable version - help message only
15+
let mut arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
16+
let mut chunk_iter = arr2.chunks_exact_mut(CHUNK_SIZE);
17+
//~^ chunks_exact_with_const_size
18+
for chunk in chunk_iter.by_ref() {}
19+
let _remainder = chunk_iter.into_remainder();
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: using `chunks_exact` with a constant chunk size
2+
--> tests/ui/chunks_exact_with_const_size_unfixable.rs:9:32
3+
|
4+
LL | let mut chunk_iter = slice.chunks_exact(CHUNK_SIZE);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: consider using `as_chunks::<CHUNK_SIZE>()` instead
8+
= note: you can access the chunks using `chunk_iter.0.iter()`, and the remainder using `chunk_iter.1`
9+
= note: `-D clippy::chunks-exact-with-const-size` implied by `-D warnings`
10+
= help: to override `-D warnings` add `#[allow(clippy::chunks_exact_with_const_size)]`
11+
12+
error: using `chunks_exact_mut` with a constant chunk size
13+
--> tests/ui/chunks_exact_with_const_size_unfixable.rs:16:31
14+
|
15+
LL | let mut chunk_iter = arr2.chunks_exact_mut(CHUNK_SIZE);
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
|
18+
= help: consider using `as_chunks_mut::<CHUNK_SIZE>()` instead
19+
= note: you can access the chunks using `chunk_iter.0.iter()`, and the remainder using `chunk_iter.1`
20+
21+
error: aborting due to 2 previous errors
22+

0 commit comments

Comments
 (0)