Add "diagnostic items" which behave like lang items #39131
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
E-medium
Call for participation: Medium difficulty. Experience needed to fix: Intermediate.
E-mentor
Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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
The text was updated successfully, but these errors were encountered: