Skip to content

wrong help message #139839

Closed
Closed
@Sherlock-Holo

Description

@Sherlock-Holo

I tried this code:

Box::pin(
                async gen {
                    loop {
                        yield tunnel_manager.next_broadcast().await;
                    }
                }
                .into_stream(),
)

I expected to see this happen:

when rustc tell me

async gen block may outlive the current function, but it borrows `tunnel_manager`, which is owned by the current function

and give me a right help message, to add the move keyword after the gen

Instead, this happened:

it give me

help: to force the async gen block to take ownership of `tunnel_manager` (and any other referenced variables), use the `move` keyword
    |
197 |                 async move gen {
    |                       ++++

For more information about this error, try `rustc --explain E0373`.

follow this help message, now rustc report

197 |                 async move gen {
    |                            ^^^ expected one of `async`, `|`, or `||`

so I have to tried async gen move, and it works for me

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (092a284ba 2025-04-13)
binary: rustc
commit-hash: 092a284ba0421695f2032c947765429fd7095796
commit-date: 2025-04-13
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Backtrace

<backtrace>

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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