2021-05-15 00:07:30 +00:00
|
|
|
#![warn(clippy::unused_async)]
|
2023-06-27 20:00:00 +00:00
|
|
|
#![feature(async_fn_in_trait)]
|
|
|
|
#![allow(incomplete_features)]
|
2021-05-14 23:45:18 +00:00
|
|
|
|
2022-06-20 12:03:27 +00:00
|
|
|
use std::future::Future;
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
2023-05-21 21:07:30 +00:00
|
|
|
mod issue10800 {
|
|
|
|
#![allow(dead_code, unused_must_use, clippy::no_effect)]
|
|
|
|
|
|
|
|
use std::future::ready;
|
|
|
|
|
|
|
|
async fn async_block_await() {
|
|
|
|
async {
|
|
|
|
ready(()).await;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn normal_block_await() {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ready(()).await;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-27 20:00:00 +00:00
|
|
|
mod issue10459 {
|
|
|
|
trait HasAsyncMethod {
|
|
|
|
async fn do_something() -> u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl HasAsyncMethod for () {
|
|
|
|
async fn do_something() -> u32 {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-14 23:45:18 +00:00
|
|
|
async fn foo() -> i32 {
|
|
|
|
4
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn bar() -> i32 {
|
|
|
|
foo().await
|
|
|
|
}
|
|
|
|
|
2022-06-20 12:03:27 +00:00
|
|
|
struct S;
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
async fn unused(&self) -> i32 {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn used(&self) -> i32 {
|
|
|
|
self.unused().await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait AsyncTrait {
|
|
|
|
fn trait_method() -> Pin<Box<dyn Future<Output = i32>>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! async_trait_impl {
|
|
|
|
() => {
|
|
|
|
impl AsyncTrait for S {
|
|
|
|
fn trait_method() -> Pin<Box<dyn Future<Output = i32>>> {
|
|
|
|
async fn unused() -> i32 {
|
|
|
|
5
|
|
|
|
}
|
|
|
|
|
|
|
|
Box::pin(unused())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
async_trait_impl!();
|
|
|
|
|
2021-05-14 23:45:18 +00:00
|
|
|
fn main() {
|
|
|
|
foo();
|
|
|
|
bar();
|
|
|
|
}
|