Skip to content

Clippy lint async_returns_async fails if you return an awaitable type #236

@danya02

Description

@danya02

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions