Skip to content

Commit 461f4a3

Browse files
committed
Add missing tests
1 parent 51585a1 commit 461f4a3

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

tests/ui/manual_memcpy.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) {
9999
dst[i] = src[i - from];
100100
}
101101

102+
#[allow(clippy::identity_op)]
103+
for i in 0..5 {
104+
dst[i - 0] = src[i];
105+
}
106+
107+
#[allow(clippy::reverse_range_loop)]
108+
for i in 0..0 {
109+
dst[i] = src[i];
110+
}
111+
102112
// `RangeTo` `for` loop - don't trigger lint
103113
for i in 0.. {
104114
dst[i] = src[i];

tests/ui/manual_memcpy.stderr

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,22 @@ LL | for i in from..from + 3 {
6767
| ^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + 3].clone_from_slice(&src[..(from + 3 - from)])`
6868

6969
error: it looks like you're manually copying between slices
70-
--> $DIR/manual_memcpy.rs:110:14
70+
--> $DIR/manual_memcpy.rs:103:14
71+
|
72+
LL | for i in 0..5 {
73+
| ^^^^ help: try replacing the loop by: `dst[..5].clone_from_slice(&src[..5])`
74+
75+
error: it looks like you're manually copying between slices
76+
--> $DIR/manual_memcpy.rs:108:14
77+
|
78+
LL | for i in 0..0 {
79+
| ^^^^ help: try replacing the loop by: `dst[..0].clone_from_slice(&src[..0])`
80+
81+
error: it looks like you're manually copying between slices
82+
--> $DIR/manual_memcpy.rs:120:14
7183
|
7284
LL | for i in 0..src.len() {
7385
| ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])`
7486

75-
error: aborting due to 11 previous errors
87+
error: aborting due to 13 previous errors
7688

0 commit comments

Comments
 (0)