rust-lang / rust-lang/rust-analyzer

Address FIXMEs for adding diagnostics

Open
#22,140 38 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics C-feature C-tracking-issue E-easy E-has-instructions
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

We have quite a lot of FIXMEs, mostly in hir-ty, for adding new diagnostics for things (and I'm constantly adding more). The shape of them is like FIXME: Emit an error ... (my own FIXMEs usually use these words, others might use similar). Most are pretty easy to do. The steps to resolve one (in inference) are:

  1. Add a variant to InferenceDiagnostic with the necessary information.
  2. Call self.push_diagnostic(diag) on the place.
  3. In hir/src/diagnostics.rs, add a new struct for the diagnostic and convert the enum variant to it in the functions of that module. Note: this struct must not use hir-ty types, only hir types.
  4. Create a new handler in ide-diagnostics/src/handlers/ for the diagnostic (follow existing handlers). A simple handler can take a few lines. Also add some tests.
  5. Call the handler from ide-diagnostics/src/lib.rs.

That's it! You can also of course customize the error message to be clearer/clever, and/or add a fix, but that is good enough.

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

Search hir-ty for a FIXME requesting a diagnostic and start by examining the surrounding inference code. Add the corresponding InferenceDiagnostic and push it there, then update hir/src/diagnostics.rs, add a handler under ide-diagnostics/src/handlers/, wire it in ide-diagnostics/src/lib.rs, and add handler tests. Done means the FIXME is resolved and the new diagnostic tests pass.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.