Skip to content

Address FIXMEs for adding diagnostics #22140

@ChayimFriedman2

Description

@ChayimFriedman2

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsdiagnostics / error reportingC-featureCategory: feature requestC-tracking-issueCategory: tracking issueE-easyE-has-instructionsIssue has some instructions and pointers to code to get started

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions