Open
Description
Description
In this code:
fn main() {
let mut w = [42];
(&mut w[..]).copy_from_slice(&[43]);
println!("{:?}", &w);
}
clippy suggests as follows:
4 | (&mut w[..]).copy_from_slice(&[43]);
| ^^^^^^^^^^^^ help: change this to: `w[..]`
This is correct as far as it goes. But a better suggestion would be just w
, implying
w.copy_from_slice(&[43]);
which also DTRT.
FTR, stable doesn't issue this lint in this situation at all. #8367 and #8355 may be relevant.
Version
rustcargo@zealot:/home/ian/Rustup/Arti/experiments$ rustc -Vv
rustc 1.60.0-nightly (a00e130da 2022-01-29)
binary: rustc
commit-hash: a00e130dae74a213338e2b095ec855156d8f3d8a
commit-date: 2022-01-29
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0
rustcargo@zealot:/home/ian/Rustup/Arti/experiments$
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
No labels