rust-lang / rust-lang/rust

Work tracking issue for moving `rustc_infer` error reporting into `rustc_trait_selection`

Open
#127,492 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-type-system C-tracking-issue T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I'm mostly just opening this for myself since I want somewhere to track the work. Look away unless you care about completely compiler-internal stuff.

The motivation for doing this is that error reporting in rustc_infer is fraught with challenges, like the lack of trait selection. This became evident in #127172, which demonstrates that the new trait solver needs trait selection in order to actually even prove that things can be equal or not. We also suffer from the lack of normalization, and to a lesser extent autoderef (though the latter isn't yet uplifted into trait selection, it very well could be, or at least replicated in some way for the purposes of diagnostics, but that requires trait selection lol)

  • Create top level rustc_trait_selection::error_reporting module (#127493)
  • Move trait error reporting to error_reporting::traits (from traits::error_reporting) (#127493)
    • Split out overflow error reporting from other error reporting (#127495)
    • Split out ambiguity error reporting from other error reporting (#127495)
    • flatten module structure of error_reporting::traits (e.g. no need to have type_err_ctxt_ext module) (#128076)
  • Move rustc_infer's error reporting to rustc_trait_selection::error_reporting::infer (#128041)
    • Move all the diagnostics from infer -> trait selection ftl file (#128041)
    • Split out region error reporting from type error reporting (#127500)
  • Pull TypeErrCtxt into rustc_trait_selection, and delete all the extension traits (since they can be inherent now) (#128041)
    • Delete can_eq_shallow (#128067)
    • Delete normalization helper from TypeErrCtxt since normalization is defined in rustc_trait_selection (#157715)
  • Audit code for anything that we can now use since error reporting lives in trait selection

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 the remaining unchecked audit item and the completed migration history in rustc_trait_selection::error_reporting and rustc_infer. Identify compiler code that can now use functionality exposed by the move, then verify each candidate with the relevant compiler tests; done means the audit is complete and any resulting follow-up work is clearly recorded.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.