Add tests for bitwise operations

This commit is contained in:
rail 2020-06-18 12:31:13 +12:00
parent 9aad38bf61
commit 4ea4a97250
2 changed files with 15 additions and 1 deletions

View file

@ -167,6 +167,14 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32])
count += 1;
count += 1;
}
// make sure parentheses are added properly to bitwise operators, which have lower precedence than
// arithmetric ones
let mut count = 0 << 1;
for i in 0..1 << 1 {
dst[count] = src[i + 2];
count += 1;
}
}
#[warn(clippy::needless_range_loop, clippy::manual_memcpy)]

View file

@ -135,8 +135,14 @@ LL | dst2[30..(src.len() + 30)].clone_from_slice(&src[..]) {
error: it looks like you're manually copying between slices
--> $DIR/manual_memcpy.rs:174:14
|
LL | for i in 0..1 << 1 {
| ^^^^^^^^^ help: try replacing the loop by: `dst[(0 << 1)..((1 << 1) + (0 << 1))].clone_from_slice(&src[2..((1 << 1) + 2)])`
error: it looks like you're manually copying between slices
--> $DIR/manual_memcpy.rs:182:14
|
LL | for i in 0..src.len() {
| ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])`
error: aborting due to 21 previous errors
error: aborting due to 22 previous errors