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.
I was making an API that returns a
tokio::sync::oneshot::Receiver
from an async function when I noticed that theclippy::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 normalasync fn
s. It turns out that this lint error comes from theasync_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.