rustdoc: Clean AST + JSON types: Yeet `WherePredicate::EqPredicate`
Open
@fmease is already working on this.
Since May 21, 2025.
A-rustdoc-json
C-cleanup
S-blocked
T-rustdoc
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
- Remove
rustdoc::clean::types::WherePredicate::EqPredicate - Remove
rustdoc_json_types::WherePredicate::EqPredicate
While equality bounds/predicates $type = $type and $type == $type (#20041) are syntactically legal and stable (if cfg'ed out), they get rejected during AST validation (which is a pass rustdoc does run) and more importantly they're not on track to becoming part of the language / being implemented anytime soon — if ever.
- Therefore HIR equality predicates (
rustc_hir::hir::WherePredicateKind::EqPredicate) should in theory never reach rustdoc's cleaning procedures. Instead of lowering them to a cleaned counterpart, we should justpanic!()/bug!()on them (or delay a bug if it turns out they're smh. reachable and return some dummy cleaned type). - Contrary to the HIR, the middle::ty IR does send us equality predicates (
rustc_type_ir::predicate::ProjectionPredicate) but these don't correspond to the aforementioned "standalone" predicates but to associated item bindings / equality constraints (as in e.g.,Iterator<Item = ()>). However, we resugar these back to their assoc item binding form, so they should never actually reach HTML/JSON rendering (assuming the resugaring step never fails).- Unfortunately, as an intermediate step we do lower projection predicates to cleaned
EqPredicateswhich prevents us from removing that enum variant for now. - For a long time now, I've wanted to rewrite predicate cleaning (to fix #113015 and #126432) which would remove that unnecessary extra step (among other niceties)
- My very WIP PR is fmease/rust#23. It stalled because it got quite nasty due to the existence of nested ATBs (assoc type bounds) (which even the compiler can't render properly, cc #127329)
- That's why this cleanup operation is (at least partially) blocked on that effort
- I want rustdoc to crash on any projection predicates it can't resugar
- Unfortunately, as an intermediate step we do lower projection predicates to cleaned
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.