Skip to content

Commit e6e736f

Browse files
committed
Add regression test for issue 236
Currently fails: error: an async construct yields a type which is itself awaitable --> tests/test.rs:1582:35 | 1582 | async fn f() -> Ready<()> { | ___________________________________^ 1583 | | future::ready(()) 1584 | | } | | ^ | | | | |_________outer async construct | awaitable value not awaited | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#async_yields_async note: the lint level is defined here --> tests/test.rs:1562:13 | 1562 | #![deny(clippy::async_yields_async)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider awaiting this value | 1582 ~ async fn f() -> Ready<()> { 1583 + future::ready(()) 1584 + }.await |
1 parent 36bcff4 commit e6e736f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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)