mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
f73879e096
Partial rewrite of `unused_io_account` to lint over Ok(_). Moved the check to `check_block` to simplify context checking for expressions and allow us to check only some expressions. For match (expr, arms) we emit a lint for io ops used on `expr` when an arm is `Ok(_)`. Also considers the cases when there are guards in the arms. It also captures `if let Ok(_) = ...` cases. For `Ok(_)` it emits a note indicating where the value is ignored. changelog: False Negatives [`unused_io_amount`]: Extended `unused_io_amount` to catch `Ok(_)`s in `If let` and match exprs.
264 lines
7.9 KiB
Text
264 lines
7.9 KiB
Text
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:10:5
|
|
|
|
|
LL | s.write(b"test")?;
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
= note: `-D clippy::unused-io-amount` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::unused_io_amount)]`
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:13:5
|
|
|
|
|
LL | s.read(&mut buf)?;
|
|
| ^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:19:5
|
|
|
|
|
LL | s.write(b"test").unwrap();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:22:5
|
|
|
|
|
LL | s.read(&mut buf).unwrap();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:27:5
|
|
|
|
|
LL | s.read_vectored(&mut [io::IoSliceMut::new(&mut [])])?;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:29:5
|
|
|
|
|
LL | s.write_vectored(&[io::IoSlice::new(&[])])?;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:37:5
|
|
|
|
|
LL | reader.read(&mut result).ok()?;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:47:5
|
|
|
|
|
LL | reader.read(&mut result).or_else(|err| Err(err))?;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:60:5
|
|
|
|
|
LL | reader.read(&mut result).or(Err(Error::Kind))?;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:68:5
|
|
|
|
|
LL | / reader
|
|
LL | |
|
|
LL | | .read(&mut result)
|
|
LL | | .or(Err(Error::Kind))
|
|
LL | | .or(Err(Error::Kind))
|
|
LL | | .expect("error");
|
|
| |________________________^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:78:5
|
|
|
|
|
LL | s.write(b"ok").is_ok();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:80:5
|
|
|
|
|
LL | s.write(b"err").is_err();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:83:5
|
|
|
|
|
LL | s.read(&mut buf).is_ok();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:85:5
|
|
|
|
|
LL | s.read(&mut buf).is_err();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:90:5
|
|
|
|
|
LL | w.write(b"hello world").await.unwrap();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `AsyncWriteExt::write_all` instead, or handle partial writes
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:96:5
|
|
|
|
|
LL | r.read(&mut buf[..]).await.unwrap();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `AsyncReadExt::read_exact` instead, or handle partial reads
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:104:5
|
|
|
|
|
LL | w.write(b"hello world");
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `AsyncWriteExt::write_all` instead, or handle partial writes
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:110:9
|
|
|
|
|
LL | w.write(b"hello world").await?;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `AsyncWriteExt::write_all` instead, or handle partial writes
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:119:9
|
|
|
|
|
LL | r.read(&mut buf[..]).await.or(Err(Error::Kind))?;
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `AsyncReadExt::read_exact` instead, or handle partial reads
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:128:5
|
|
|
|
|
LL | w.write(b"hello world").await.unwrap();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `AsyncWriteExt::write_all` instead, or handle partial writes
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:134:5
|
|
|
|
|
LL | r.read(&mut buf[..]).await.unwrap();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `AsyncReadExt::read_exact` instead, or handle partial reads
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:147:11
|
|
|
|
|
LL | match s.write(b"test") {
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
note: the result is consumed here, but the amount of I/O bytes remains unhandled
|
|
--> $DIR/unused_io_amount.rs:149:9
|
|
|
|
|
LL | Ok(_) => todo!(),
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:155:11
|
|
|
|
|
LL | match s.read(&mut buf) {
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
note: the result is consumed here, but the amount of I/O bytes remains unhandled
|
|
--> $DIR/unused_io_amount.rs:157:9
|
|
|
|
|
LL | Ok(_) => todo!(),
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:164:11
|
|
|
|
|
LL | match s.read(&mut [0u8; 4]) {
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
note: the result is consumed here, but the amount of I/O bytes remains unhandled
|
|
--> $DIR/unused_io_amount.rs:166:9
|
|
|
|
|
LL | Ok(_) => todo!(),
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:173:11
|
|
|
|
|
LL | match s.write(b"test") {
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
note: the result is consumed here, but the amount of I/O bytes remains unhandled
|
|
--> $DIR/unused_io_amount.rs:175:9
|
|
|
|
|
LL | Ok(_) => todo!(),
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error: read amount is not handled
|
|
--> $DIR/unused_io_amount.rs:186:8
|
|
|
|
|
LL | if let Ok(_) = s.read(&mut [0u8; 4]) {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Read::read_exact` instead, or handle partial reads
|
|
note: the result is consumed here, but the amount of I/O bytes remains unhandled
|
|
--> $DIR/unused_io_amount.rs:186:12
|
|
|
|
|
LL | if let Ok(_) = s.read(&mut [0u8; 4]) {
|
|
| ^^^^^
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:193:8
|
|
|
|
|
LL | if let Ok(_) = s.write(b"test") {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
note: the result is consumed here, but the amount of I/O bytes remains unhandled
|
|
--> $DIR/unused_io_amount.rs:193:12
|
|
|
|
|
LL | if let Ok(_) = s.write(b"test") {
|
|
| ^^^^^
|
|
|
|
error: written amount is not handled
|
|
--> $DIR/unused_io_amount.rs:200:8
|
|
|
|
|
LL | if let Ok(..) = s.write(b"test") {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: use `Write::write_all` instead, or handle partial writes
|
|
note: the result is consumed here, but the amount of I/O bytes remains unhandled
|
|
--> $DIR/unused_io_amount.rs:200:12
|
|
|
|
|
LL | if let Ok(..) = s.write(b"test") {
|
|
| ^^^^^^
|
|
|
|
error: aborting due to 28 previous errors
|
|
|