Skip to content

_ replacement suggestion when returning async closures is broken #148493

@cyrgani

Description

@cyrgani

Code

fn ord() -> _ { async || {} }

Current output

error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> src/lib.rs:1:13 | 1 | fn ord() -> _ { | ^ not allowed in type signatures | help: replace with the correct return type | 1 - fn ord() -> _ { 1 + fn ord() -> {async closure@src/lib.rs:2:5: 2:13} { |

Desired output

error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> src/lib.rs:1:13 | 1 | fn ord() -> _ { | ^ not allowed in type signatures | help: replace with the correct return type | 1 - fn ord() -> _ { 1 + fn ord() -> impl AsyncFn() { |

Rationale and extra context

This works correctly if you remove either async or ||.
Found from #148488.

Other cases

Rust Version

Nightly version: 1.93.0-nightly (2025-11-03 20383c9f1d84eb9b9c66)

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-async-closures`async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions