Skip to content

Commit ea573a3

Browse files
authored
Merge pull request #237 from dtolnay/asyncyieldsasync
Suppress async_yields_async clippy correctness lint in generated code
2 parents 36bcff4 + 54cc1ce commit ea573a3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/expand.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub fn expand(input: &mut Item, is_local: bool) {
119119
fn lint_suppress_with_body() -> Attribute {
120120
parse_quote! {
121121
#[allow(
122+
clippy::async_yields_async,
122123
clippy::let_unit_value,
123124
clippy::no_effect_underscore_binding,
124125
clippy::shadow_same,

tests/test.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,3 +1556,31 @@ pub mod issue234 {
15561556
async fn f(Tuple { 1: _int, .. }: Tuple<Droppable, i32>) {}
15571557
}
15581558
}
1559+
1560+
// https://github.com/dtolnay/async-trait/issues/236
1561+
pub mod issue236 {
1562+
#![deny(clippy::async_yields_async)]
1563+
#![allow(clippy::manual_async_fn)]
1564+
1565+
use async_trait::async_trait;
1566+
use std::future::{self, Future, Ready};
1567+
1568+
// Does not trigger the lint.
1569+
pub async fn async_fn() -> Ready<()> {
1570+
future::ready(())
1571+
}
1572+
1573+
#[allow(clippy::async_yields_async)]
1574+
pub fn impl_future_fn() -> impl Future<Output = Ready<()>> {
1575+
async { future::ready(()) }
1576+
}
1577+
1578+
// The async_trait attribute turns the former into the latter, so we make it
1579+
// put its own allow(async_yeilds_async) to remain consistent with async fn.
1580+
#[async_trait]
1581+
pub trait Trait {
1582+
async fn f() -> Ready<()> {
1583+
future::ready(())
1584+
}
1585+
}
1586+
}

0 commit comments

Comments
 (0)