Skip to content

Add "diagnostic items" which behave like lang items #39131

Closed
@Manishearth

Description

@Manishearth

It would be nice to have a (rustc-only) system of that lets us annotate structs with things like #[diagnostic_item="String"].

This lets us improve the diagnostics in special cases involving that type (e.g. #39116 (comment)). Clippy currently string-compares the path to do this, but that's hacky and I would rather we avoided that code in rustc.

It's something that would only get hit when we have an error case, so we probably can just store these in a hash map or something.

cc @jonathandturner @nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions