mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 13:43:17 +00:00
2891d8f72f
This lets us detect more complex situations: `async { x.await }` is simplified into `x` if: - `x` is an expression without side-effect - or `x` is an async block itself In both cases, no part of the `async` expression can be part of a macro expansion.
74 lines
2.7 KiB
Text
74 lines
2.7 KiB
Text
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:15:13
|
|
|
|
|
LL | let x = async { f.await };
|
|
| ^^^^^^^^^^^^^^^^^ help: you can reduce it to: `f`
|
|
|
|
|
= note: `-D clippy::redundant-async-block` implied by `-D warnings`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:22:16
|
|
|
|
|
LL | let fut2 = async { fut1.await };
|
|
| ^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut1`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:26:16
|
|
|
|
|
LL | let fut2 = async move { fut1.await };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut1`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:29:15
|
|
|
|
|
LL | let fut = async { async { 42 }.await };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { 42 }`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:45:5
|
|
|
|
|
LL | async move { fut.await }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:58:5
|
|
|
|
|
LL | async move { fut.await }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:63:5
|
|
|
|
|
LL | async { f.await }
|
|
| ^^^^^^^^^^^^^^^^^ help: you can reduce it to: `f`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:86:5
|
|
|
|
|
LL | async { async { f().await + 1 }.await }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { f().await + 1 }`
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:149:13
|
|
|
|
|
LL | async { async { 42 }.await }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { 42 }`
|
|
...
|
|
LL | mac!()
|
|
| ------ in this macro invocation
|
|
|
|
|
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: this async expression only awaits a single future
|
|
--> $DIR/redundant_async_block.rs:169:13
|
|
|
|
|
LL | async { async { $e }.await }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { $e }`
|
|
...
|
|
LL | mac!(42)
|
|
| -------- in this macro invocation
|
|
|
|
|
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
error: aborting due to 10 previous errors
|
|
|