about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-02-10 18:05:11 +0100
committerSamuel Tardieu <sam@rfc1149.net>2025-02-15 15:56:41 +0100
commit44aa75fd2aa94850103215c8e67b0d0baa24b6b7 (patch)
tree08cec845928758dc1e5fe1edd11e34228d21947e /tests
parent35ad69c124d67faa72e3a61f77118d1fb0585002 (diff)
downloadrust-44aa75fd2aa94850103215c8e67b0d0baa24b6b7.tar.gz
rust-44aa75fd2aa94850103215c8e67b0d0baa24b6b7.zip
`manual_slice_fill`: initializer must not reference the iterator
```rust
let mut tmp = vec![1, 2, 3];
for b in &mut tmp {
    *b = !*b;
}
```

must not suggest the invalid `tmp.fill(!*b)`.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/manual_slice_fill.fixed8
-rw-r--r--tests/ui/manual_slice_fill.rs8
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/manual_slice_fill.fixed b/tests/ui/manual_slice_fill.fixed
index 80e271117fc..bba863247f5 100644
--- a/tests/ui/manual_slice_fill.fixed
+++ b/tests/ui/manual_slice_fill.fixed
@@ -115,3 +115,11 @@ fn issue_14192() {
         tmp[0] = i;
     }
 }
+
+fn issue14189() {
+    // Should not lint because `!*b` is not constant
+    let mut tmp = vec![1, 2, 3];
+    for b in &mut tmp {
+        *b = !*b;
+    }
+}
diff --git a/tests/ui/manual_slice_fill.rs b/tests/ui/manual_slice_fill.rs
index f758f47bbcb..44c60dc40f0 100644
--- a/tests/ui/manual_slice_fill.rs
+++ b/tests/ui/manual_slice_fill.rs
@@ -128,3 +128,11 @@ fn issue_14192() {
         tmp[0] = i;
     }
 }
+
+fn issue14189() {
+    // Should not lint because `!*b` is not constant
+    let mut tmp = vec![1, 2, 3];
+    for b in &mut tmp {
+        *b = !*b;
+    }
+}