-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
I recently moved to rust 1.86, and got a false positive/invalid suggestion from clippy about manual slice filling below you can find the reproducer.
I think the report is false positive as I am not actually writing the same value into the slice for each element so I am not filling it but rather applying the same operator to each element so if we are going to be transforming it to something it should be: bytes.iter_mut().for_each(|b| *b = !*b);
Reproducer
for the following piece:
for b in &mut bytes {
*b = !*b;
}
I got:
warning: manually filling a slice
--> sway-types/src/u256.rs:140:9
|
140 | / for b in &mut bytes {
141 | | *b = !*b;
142 | | }
| |_________^ help: try: `bytes.fill(!*b);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_slice_fill
= note: `#[warn(clippy::manual_slice_fill)]` on by default
If this suggestion is applied we get a compile error as b
is not a valid variable name anymore.
I expected to see this happen: either no report or suggest bytes.iter_mut().for_each(|b| *b = !*b);
Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: aarch64-apple-darwin
release: 1.86.0
LLVM version: 19.1.7
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have