Skip to content

wrong help message #139839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Sherlock-Holo opened this issue Apr 15, 2025 · 1 comment · Fixed by #139871
Closed

wrong help message #139839

Sherlock-Holo opened this issue Apr 15, 2025 · 1 comment · Fixed by #139871
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Sherlock-Holo
Copy link

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>

@Sherlock-Holo Sherlock-Holo added the C-bug Category: This is a bug. label Apr 15, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 15, 2025
@jieyouxu jieyouxu added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 15, 2025
@GuillaumeGomez
Copy link
Member

Taking a look.

@GuillaumeGomez GuillaumeGomez self-assigned this Apr 15, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Apr 15, 2025
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 16, 2025
…ompiler-errors

Fix wrong "move keyword" suggestion for async gen block

Fixes rust-lang#139839.

It was just missing a string comparison with `async gen`.
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 16, 2025
…ompiler-errors

Fix wrong "move keyword" suggestion for async gen block

Fixes rust-lang#139839.

It was just missing a string comparison with `async gen`.
@bors bors closed this as completed in a1de2a2 Apr 16, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 16, 2025
Rollup merge of rust-lang#139871 - GuillaumeGomez:async-gen-move, r=compiler-errors

Fix wrong "move keyword" suggestion for async gen block

Fixes rust-lang#139839.

It was just missing a string comparison with `async gen`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants