rust-lang / rust-lang/rust

feature(gen_blocks): cannot use the ? operator in a gen block that returns ()

Open
#117,486 6 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-gen_blocks T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

As per gen_blocks RFC:

Even when ? is used within a gen block, the block must return a value of type unit or !. That is, it does not return a value of Some(..), Ok(..), or Continue(..) as other such blocks might.

But currently upon using ? an error occurs: cannot use the ? operator in a gen block that returns ()

To reproduce: https://godbolt.org/z/4fGT9EM8q

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.

Research direction

Start by reproducing the error with the Godbolt example linked in the issue and read the gen_blocks RFC rule quoted in the report. Trace how the compiler handles ? in a gen block returning (), then verify that the example compiles with the intended unit-or-never behavior and that existing gen-block diagnostics remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.