Skip to content

unused_async for an async fn in a trait #14704

Closed
@onlycs

Description

@onlycs

Summary

If you have an async function in a trait that does nothing by default:

trait MyTrait {
  // having a body here makes its implementation optional
  async fn completed(self, ...) {}
}

sure, the async isn't used, but you want implementers to be able to use await in an overridden implementation. In this case, unused_async should not be warned

Lint Name

unused_async

Reproducer

I tried this code:

pub trait Action {
    // ...

    async fn cancel(self: Arc<Self>) {}
}

I saw this happen:

clippy: unused `async` for function with no await statements
consider removing the `async` from this function

I expected to see this happen:
No warning

Version

rustc 1.88.0-nightly (0b45675cf 2025-03-31)
binary: rustc
commit-hash: 0b45675cfcec57f30a3794e1a1e18423aa9cf200
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1

Additional Labels

  • I-suggestion-causes-warning

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions