about summary refs log tree commit diff
diff options
context:
space:
mode:
authorrail <12975677+rail-rain@users.noreply.github.com>2020-06-18 12:31:13 +1200
committerrail <12975677+rail-rain@users.noreply.github.com>2020-09-25 09:02:05 +1200
commit4ea4a972500a8ddecfc737d51eec960324dcb02f (patch)
tree8579e8916bc61953d6092c5d89d6c8350c799037
parent9aad38bf614c3fb6d306f5dec4a0af606bb3c9c8 (diff)
downloadrust-4ea4a972500a8ddecfc737d51eec960324dcb02f.tar.gz
rust-4ea4a972500a8ddecfc737d51eec960324dcb02f.zip
Add tests for bitwise operations
-rw-r--r--tests/ui/manual_memcpy.rs8
-rw-r--r--tests/ui/manual_memcpy.stderr8
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/ui/manual_memcpy.rs b/tests/ui/manual_memcpy.rs
index 87bfb4fdd16..4846ab5eaaa 100644
--- a/tests/ui/manual_memcpy.rs
+++ b/tests/ui/manual_memcpy.rs
@@ -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)]
diff --git a/tests/ui/manual_memcpy.stderr b/tests/ui/manual_memcpy.stderr
index e6bef9981a3..d189bde0508 100644
--- a/tests/ui/manual_memcpy.stderr
+++ b/tests/ui/manual_memcpy.stderr
@@ -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