rust-lang / rust-lang/rust-analyzer

TypeMismatch closure display style

Open
#22,400 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

fn foo() -> Option<impl Fn() -> i32> {
    Some(|| {})
}

Outputs diagnostic: expected Option<impl Fn() -> i32>, found Option<{closure#153601}>

Expect diagnostic: expected Option<impl Fn() -> i32>, found Option<impl Fn()>

But could this cause confusion? Perhaps similar to #22331

And this may be configurable, but currently only the configuration of inlayhints is available, I don't know if it needs to be reused

rust-analyzer 0.4.2897-standalone

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 TypeMismatch diagnostic with the Rust snippet in the issue, then trace the rust-analyzer diagnostic rendering path for closure types. Compare the current and expected display, and determine whether configuration should reuse the existing inlay-hint configuration. Done means the diagnostic uses the agreed closure display without introducing confusing output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.