Closed
Description
Lint name: unused_io_amount
I tried this code:
fn test(file: &str) -> Option<()> {
let mut reader = std::fs::File::open(file).ok()?;
let mut result = [0u8; 0];
// reader.read(&mut result).unwrap(); // clippy correctly warns about this
reader.read(&mut result).ok()?; // clippy does not warn about this
Some(())
}
<code>
I expected to see this happen: explanation
If you use reader.read(&mut result).unwrap()
, clippy correctly triggers error "read amount is not handled. Use Read::read_exact
instead"
Instead, this happened: explanation
Appending .ok()?
consumes the error, but clippy does not report the unused_io_amount
warning any more.
Meta
cargo clippy -V
: clippy 0.1.51 (2fd73fa 2021-03-23)rustc -Vv
:
rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1