rust-lang / rust-lang/rust-analyzer
Address FIXMEs for adding diagnostics
Nobody has claimed this yet.
- 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:
- Add a variant to
InferenceDiagnosticwith the necessary information. - Call
self.push_diagnostic(diag)on the place. - 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 usehir-tytypes, onlyhirtypes. - 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. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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