Skip to content

disallowed_methods triggers on the desugared form of .await #16185

@BatmanAoD

Description

@BatmanAoD

Summary

I am trying to forbid direct use of std::futures::Future::poll1. However, adding this to the disallowed_methods config causes the lint to trigger on every use of .await.

I don't know exactly how this is possible, since my understanding is that await is handled by the compiler and does not desugar into non-async Rust code like a macro would. So this seems like a false positive to me.

Lint Name

disallowed_methods

Reproducer

I tried this code:

pub async fn test() {
    inner().await
}

async fn inner() {}

with this clippy.toml:

disallowed-methods = ["std::future::Future::poll"]

I saw this happen:

error: use of a disallowed method `std::future::Future::poll`
 --> src/lib.rs:2:13
  |
2 |     inner().await
  |             ^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
  = note: requested on the command line with `-D clippy::disallowed-methods`

error: could not compile `clippy-disallowed` (lib) due to 1 previous error

I expected no error.

Version

rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: aarch64-apple-darwin
release: 1.90.0
LLVM version: 20.1.8

Additional Labels

No response

Footnotes

  1. The intent is to provide more safeguards for cancel correctness. I am requiring an expect annotation for any code that polls one or more futures without completing that future. Since await polls a future to completion, it's not inherently problematic (though of course it's possible for a future itself to leave other futures in an incomplete state, so I am also disallowing methods that produce such futures, such as futures::stream::StreamExt::next). Of course, partial completion of futures is often unavoidable (for instance in a select!), so this lint is set to merely deny, not forbid.

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