rust-lang / rust-lang/rust-analyzer

Better Error Message For Incorrect -> Arrow In Closure?

Open
#18,512 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Coming from the TypeScript world it's easy to accidentally add an arrow "->" when doing a one-liner closure, but I feel like this is a very cryptic error message that it gives...


Image


Is there any way to have it suggest , "if you meant for this to be a closure, remove the arrow"?


Thanks! 👍 🦀


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 reported one-line closure syntax in rust-analyzer and locate the diagnostic entry point that emits the cryptic error. Done means the diagnostic explains that a closure should omit -> when that is the intended syntax, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.