rust-lang / rust-lang/rust

Invalid suggestion for `AsyncFnOnce` trait object

Open
#134,182 1 comment 2 reactions 1 assignee View on GitHub

@compiler-errors is already working on this.

Since Dec 11, 2024.

A-async-closures A-diagnostics A-dyn-trait T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![feature(async_closure)]

pub fn f(x: &dyn AsyncFnOnce()) {}
Current output
error[E0191]: the value of the associated type `CallOnceFuture` in `AsyncFnOnce` must be specified
 --> src/main.rs:3:18
  |
3 | pub fn f(x: &dyn AsyncFnOnce()) {}
  |                  ^^^^^^^^^^^^^ help: specify the associated type: `AsyncFnOnce()<CallOnceFuture = Type>`
Desired output
???
Rationale and extra context

The suggested replacement pub fn f(x: &dyn AsyncFnOnce()<CallOnceFuture = Type>) {} is not valid syntax.

Since dyn Async* is not supported, perhaps it should just say that? I don't know what the plans are here.

Other cases

Rust Version
rustc 1.85.0-nightly (a224f3807 2024-12-09)
binary: rustc
commit-hash: a224f3807e58afc9353510f1d556c607d367545d
commit-date: 2024-12-09
host: aarch64-apple-darwin
release: 1.85.0-nightly
LLVM version: 19.1.5
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.