diff options
| author | Steven Casper <sebastiancasper3@gmail.com> | 2022-10-31 12:50:59 -0700 |
|---|---|---|
| committer | Steven Casper <sebastiancasper3@gmail.com> | 2022-10-31 12:50:59 -0700 |
| commit | 6dcade0692fc516752c811d2b05302f2ed97aaeb (patch) | |
| tree | 1ef8fcab22ee0b8b5f8c144a2981d8ccd8dbae87 /tests | |
| parent | 37d338c1efd7840fa96c5eaeaa5785094efdab07 (diff) | |
Implement let_underscore_future
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/let_underscore_future.rs | 20 | ||||
| -rw-r--r-- | tests/ui/let_underscore_future.stderr | 27 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/ui/let_underscore_future.rs b/tests/ui/let_underscore_future.rs new file mode 100644 index 00000000000..d8f54cdca91 --- /dev/null +++ b/tests/ui/let_underscore_future.rs @@ -0,0 +1,20 @@ +use std::future::Future; + +async fn some_async_fn() {} + +fn sync_side_effects() {} +fn custom() -> impl Future<Output = ()> { + sync_side_effects(); + async {} +} + +fn do_something_to_future(future: &mut impl Future<Output = ()>) {} + +fn main() { + let _ = some_async_fn(); + let _ = custom(); + + let mut future = some_async_fn(); + do_something_to_future(&mut future); + let _ = future; +} diff --git a/tests/ui/let_underscore_future.stderr b/tests/ui/let_underscore_future.stderr new file mode 100644 index 00000000000..f1b9b1d709e --- /dev/null +++ b/tests/ui/let_underscore_future.stderr @@ -0,0 +1,27 @@ +error: non-binding let on a future + --> $DIR/let_underscore_future.rs:14:5 + | +LL | let _ = some_async_fn(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider awaiting the future or dropping explicitly with `std::mem::drop` + = note: `-D clippy::let-underscore-future` implied by `-D warnings` + +error: non-binding let on a future + --> $DIR/let_underscore_future.rs:15:5 + | +LL | let _ = custom(); + | ^^^^^^^^^^^^^^^^^ + | + = help: consider awaiting the future or dropping explicitly with `std::mem::drop` + +error: non-binding let on a future + --> $DIR/let_underscore_future.rs:19:5 + | +LL | let _ = future; + | ^^^^^^^^^^^^^^^ + | + = help: consider awaiting the future or dropping explicitly with `std::mem::drop` + +error: aborting due to 3 previous errors + |
