[unused_async]: don't lint on async trait impls

This commit is contained in:
y21 2023-06-27 22:00:00 +02:00
parent 2e329050c9
commit a43bfefd19
3 changed files with 34 additions and 6 deletions

View file

@ -1,4 +1,6 @@
#![warn(clippy::unused_async)]
#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]
use std::future::Future;
use std::pin::Pin;
@ -23,6 +25,18 @@ mod issue10800 {
}
}
mod issue10459 {
trait HasAsyncMethod {
async fn do_something() -> u32;
}
impl HasAsyncMethod for () {
async fn do_something() -> u32 {
1
}
}
}
async fn foo() -> i32 {
4
}

View file

@ -1,5 +1,5 @@
error: unused `async` for function with no await statements
--> $DIR/unused_async.rs:11:5
--> $DIR/unused_async.rs:13:5
|
LL | / async fn async_block_await() {
LL | | async {
@ -10,14 +10,14 @@ LL | | }
|
= help: consider removing the `async` from this function
note: `await` used in an async block, which does not require the enclosing function to be `async`
--> $DIR/unused_async.rs:13:23
--> $DIR/unused_async.rs:15:23
|
LL | ready(()).await;
| ^^^^^
= note: `-D clippy::unused-async` implied by `-D warnings`
error: unused `async` for function with no await statements
--> $DIR/unused_async.rs:26:1
--> $DIR/unused_async.rs:40:1
|
LL | / async fn foo() -> i32 {
LL | | 4
@ -27,7 +27,7 @@ LL | | }
= help: consider removing the `async` from this function
error: unused `async` for function with no await statements
--> $DIR/unused_async.rs:37:5
--> $DIR/unused_async.rs:51:5
|
LL | / async fn unused(&self) -> i32 {
LL | | 1