-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-async-closures`async || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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 || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.