compiler-team
compiler-team copied to clipboard
Create `#[rustc_on_type_error]` mimicking `#[rustc_on_unimplemented]` for E0308 customization
Proposal
#[rustc_on_unimplemented]
has shown its value, despite its many limitations. There are plenty of customized errors in the stdlib that would otherwise require careful customization of the error being emitted while it is being constructed. Type errors in particular currently have lots of special checks, looking at what types are involved to customize the output as appropriate to reduce confusion. We can mimic the same mechanism that #[rustc_on_unimplemented]
uses in a new #[rustc_on_type_error]
attribute. This would annotate stdlib types and let us replace or add additional output to E0308 errors. This would also lower the barrier to entry for new contributors desiring to customize the type error output.
This feature would only be an implementation detail for the stdlib, which means the API surface doesn't need strong stability guarantees and it enables the possibility of alternative Rust compilers can use these to provide similar diagnostics as rustc
.
Mentors or Reviewers
estebank
Process
The main points of the Major Change Process are as follows:
- [x] File an issue describing the proposal.
- [ ] A compiler team member or contributor who is knowledgeable in the area can second by writing
@rustbot second
.- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
-C flag
, then full team check-off is required. - Compiler team members can initiate a check-off via
@rfcbot fcp merge
on either the MCP or the PR.
- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
- [ ] Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.
You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
cc @rust-lang/compiler @rust-lang/compiler-contributors
@rustbot second
@rustbot label -final-comment-period +major-change-accepted