rust-lang / rust-lang/rust

Tracking Issue for #[diagnostic::on_type_error]

Open
#155,382 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics B-experimental B-unstable C-tracking-issue S-tracking-impl-incomplete T-compiler T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The feature gate for the issue is #![feature(diagnotic_on_type_err)].

Description of the feature

Similar to other diagnostic attribute, the goal of diagnostic::on_type_error is to allow crate authors to attach custom notes to type errors involving their types, improving diagnostics for common patterns such as wrapper types where users forget to access the inner value or different inner type or outer value.

As agreed upon, see https://github.com/rust-lang/rust/pull/155200#issuecomment-4256434080, the semantic will only be:

  • only note is supported (not message or label)
  • the annotated ADT must have exactly one generic type parameter
  • More advanced features such as filtering based on types or generics will supported in the future

Minimally for now, we will be supporting:

#[diagnostic::on_type_error(
    note = "text",
)]
struct S<T>(T);
About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps
  • Implement the RFC (cc @rust-lang/XXX -- can anyone write up mentoring
    instructions?)
  • Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
  • Style updates for any new syntax ([nightly-style-procedure])
    • Style team decision on new formatting
    • Formatting for new syntax has been added to the [Style Guide]
    • (non-blocking) Formatting has been implemented in rustfmt
  • Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])
Implementation history

https://github.com/rust-lang/rust/pull/155200

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading PR #155200 and the feature description to understand the current implementation of diagnostic::on_type_error. Use the tracking checklist and the rustc-dev-guide, documentation, and Style Guide links to identify remaining work. Done means the implementation, documentation, syntax style decision and formatting, and stabilization steps are complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.