Repository navigation
automatic fix tries to remove #[async_recursion] annotation #17831
Copy link
Copy link
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Summary
You were the Chosen One! It was said that you would destroy the Sith, not join them!
Clippy tries to break perfectly working code then fails.
Reproducer
Code:
[dependencies]
async-recursion = "=1.1.1"#[async_recursion::async_recursion]
pub async fn f() {
f().await
}Current output:
error: errors present after applying fixes to crate `clippy_repro_async_recursion`
--> src/lib.rs
= cause: error[E0733]: recursion in an async fn requires boxing
--> src/lib.rs:1:1
|
1 | pub async fn f() {
| ^^^^^^^^^^^^^^^^
2 | f().await
| --------- recursive call here
|
= note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0733`.
help: to report this as a bug, open an issue at https://github.com/rust-lang/rust-clippy/issues, quoting the full output of this command
help: to possibly apply more fixes, pass in the `--broken-code` flag
note: original diagnostics will follow:
warning: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]`
--> src/lib.rs:1:36
|
1 | #[async_recursion::async_recursion]
| _-----------------------------------^
| | |
| | help: remove the attribute
2 | | pub async fn f() {
| |_^
|
note: the return type is pinned boxed `std::future::Future` trait object
--> src/lib.rs:1:1
|
1 | #[async_recursion::async_recursion]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: alternatively, you may add an explicit reason to the `must_use` attribute
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.99.0/index.html#double_must_use
= note: `#[warn(clippy::double_must_use)]` on by default
= note: this warning originates in the attribute macro `async_recursion::async_recursion` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: `clippy-repro-async-recursion` (lib) generated 1 warning (run `cargo clippy --fix --lib -p clippy-repro-async-recursion -- --no-deps` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
Desired output:
Nothing?
Version
rustc 1.99.0 (b940084d7 2026-09-28)
binary: rustc
commit-hash: b940084d7eb6a299eb4bfeb8e34901bc051e7ac4
commit-date: 2026-09-28
host: x86_64-unknown-linux-gnu
release: 1.99.0
LLVM version: 23.1.1
Additional Labels
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.I-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Activity
pacak commentedon Oct 1, 2026
Now, if code does not actually need the recursion
it prints this
And silently removes it.
Still wrong - I don't see a
#[must_use]and removing it might break some code where recursion is used conditionally.CommanderStorm commentedon Oct 1, 2026
#[async_recursion..has an#[must_use]inside it.The
double_must_uselint should not be triggered inside macros.That this points to the outer attribute is a bit unfortunate/funny.
@rustbot label "good first issue"
Our docs about macros are here ^^
https://doc.rust-lang.org/nightly/clippy/development/macro_expansions.html
Mitshah2406 commentedon Oct 1, 2026
@rustbot claim
djc commentedon Oct 2, 2026
This sounds like a good improvement to me.