Skip to content

Commit

Permalink
Merge pull request #237 from dtolnay/asyncyieldsasync
Browse files Browse the repository at this point in the history
Suppress async_yields_async clippy correctness lint in generated code
  • Loading branch information
dtolnay committed Jan 30, 2023
2 parents 36bcff4 + 54cc1ce commit ea573a3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub fn expand(input: &mut Item, is_local: bool) {
fn lint_suppress_with_body() -> Attribute {
parse_quote! {
#[allow(
clippy::async_yields_async,
clippy::let_unit_value,
clippy::no_effect_underscore_binding,
clippy::shadow_same,
Expand Down
28 changes: 28 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,3 +1556,31 @@ pub mod issue234 {
async fn f(Tuple { 1: _int, .. }: Tuple<Droppable, i32>) {}
}
}

// https://github.com/dtolnay/async-trait/issues/236
pub mod issue236 {
#![deny(clippy::async_yields_async)]
#![allow(clippy::manual_async_fn)]

use async_trait::async_trait;
use std::future::{self, Future, Ready};

// Does not trigger the lint.
pub async fn async_fn() -> Ready<()> {
future::ready(())
}

#[allow(clippy::async_yields_async)]
pub fn impl_future_fn() -> impl Future<Output = Ready<()>> {
async { future::ready(()) }
}

// The async_trait attribute turns the former into the latter, so we make it
// put its own allow(async_yeilds_async) to remain consistent with async fn.
#[async_trait]
pub trait Trait {
async fn f() -> Ready<()> {
future::ready(())
}
}
}

0 comments on commit ea573a3

Please sign in to comment.