dtolnay / async-trait

Type erasure for async trait methods

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clippy lint `async_returns_async` fails if you return an awaitable type

danya02 opened this issue · comments

I was making an API that returns a tokio::sync::oneshot::Receiver from an async function when I noticed that the
clippy::async_returns_async lint doesn't like me doing this. Originally I thought that this is in fact a poor API design choice, but this doesn't happen in normal async fns. It turns out that this lint error comes from the async_trait macro's expansion.

Here's my code example. The error ultimately comes from the fact that the function's code gets wrapped in an async move block, which according to Clippy shouldn't be returning a future.

I think just putting a #[allow(clippy::async_yields_async)] on the generated function should be sufficient to deal with this.