-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
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
-
The intent is to provide more safeguards for cancel correctness. I am requiring an
expectannotation for any code that polls one or more futures without completing that future. Sinceawaitpolls 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 asfutures::stream::StreamExt::next). Of course, partial completion of futures is often unavoidable (for instance in aselect!), so this lint is set to merelydeny, notforbid. ↩