rust-lang / rust-lang/rust-analyzer

rust-analyzer should not emit macro-errors when macro input contains an unclosed delimiter

Open
#19,782 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Something which frequently frustrates me with rust-analyzer:

  1. I am editing a Kas widget (to reproduce: clone Kas, pick any widget (but especially a large one; maybe try Spinner), and start typing a new fn with an unclosed brace: {)
  2. RA correctly emits

    [rust-analyzer] (syntax-error) Syntax Error: expected R_CURLY

  3. RA also emits

    [rust-analyzer] (macro-error) unexpected end of input, expected one of: enum, struct, type, union

The latter error causes the whole impl_scope to be marked as erroneous by the editor, making it harder to focus on the actual error.

Meanwhile, cargo check will only report

error: this file contains an unclosed delimiter
[details omitted]

Macros cannot be evaluated on input that won't even tokenize.

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

Reproduce the diagnostic sequence by following the Kas widget example and typing an unclosed brace in a new function. Trace where rust-analyzer produces the macro-error alongside the syntax-error; done means only the unclosed-delimiter syntax diagnostic remains and the surrounding impl_scope is not marked erroneous.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.