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
InferenceDiagnostic with 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 use hir-ty types, only hir types.
- 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.
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:InferenceDiagnosticwith the necessary information.self.push_diagnostic(diag)on the place.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.ide-diagnostics/src/handlers/for the diagnostic (follow existing handlers). A simple handler can take a few lines. Also add some tests.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.