rust-clippy/tests/ui/let_underscore_future.rs

26 lines
694 B
Rust
Raw Normal View History

2022-10-31 19:50:59 +00:00
use std::future::Future;
2023-07-27 11:40:22 +00:00
//@no-rustfix
2022-10-31 19:50:59 +00:00
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 = ()>) {}
//~^ ERROR: this argument is a mutable reference, but not used mutably
//~| NOTE: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`
2022-10-31 19:50:59 +00:00
fn main() {
let _ = some_async_fn();
//~^ ERROR: non-binding `let` on a future
2022-10-31 19:50:59 +00:00
let _ = custom();
//~^ ERROR: non-binding `let` on a future
2022-10-31 19:50:59 +00:00
let mut future = some_async_fn();
do_something_to_future(&mut future);
let _ = future;
//~^ ERROR: non-binding `let` on a future
2022-10-31 19:50:59 +00:00
}