Closed
Description
Summary
As the heuristic is checking if the next statement of an empty vec includes read(&mut v)
, if the next statement/expression is a block with resize
before read
, the lint is still fired.
Lint Name
read_zero_byte_vec
Reproducer
I tried this code:
let mut v = Vec::new();
{
v.resize(10, 0);
r.read(&mut v).unwrap();
}
I saw this happen:
error: reading zero byte data to `Vec`
--> src/main.rs:10:5
|
130 | / {
131 | | v.resize(10, 0);
132 | | r.read(&mut v).unwrap();
133 | | }
| |_____^
|
= note: `#[deny(clippy::read_zero_byte_vec)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#read_zero_byte_vec
I expected to not seeing this lint fired off.
Version
rustc 1.64.0-nightly (0f4bcadb4 2022-07-30)
binary: rustc
commit-hash: 0f4bcadb46006bc484dad85616b484f93879ca4e
commit-date: 2022-07-30
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
Additional Labels
No response