rust-lang / rust-lang/rust-analyzer

Closure returning a generator breaks type inference

Open
#15,724 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ty C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Minimal repro

#![feature(generators)]

fn main() {
    _ = || || yield 1;
}

Results in [ERROR hir_ty::infer::closure] closure type is always closure being printed by the language server after each keystroke.

Versions

rust-analyzer version: tried both 0.3.1681-standalone (0840038f0 2023-09-30) and 0.4.1686-standalone (b1f89a84a 2023-10-06)

rustc version: rustc 1.75.0-nightly (2bbb61989 2023-10-04)

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 minimal Rust generator and nested-closure example with the affected rust-analyzer versions. Inspect the hir_ty::infer::closure diagnostic path and add a regression test for the snippet. Done means the erroneous "closure type is always closure" message no longer appears after keystrokes.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.