Skip to content

rustdoc: Clean AST + JSON types: Yeet WherePredicate::EqPredicate #141368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks
fmease opened this issue May 21, 2025 · 2 comments
Open
2 tasks

rustdoc: Clean AST + JSON types: Yeet WherePredicate::EqPredicate #141368

fmease opened this issue May 21, 2025 · 2 comments
Assignees
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented May 21, 2025

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 just panic!()/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 EqPredicates which prevents us from removing that type 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
@fmease fmease self-assigned this May 21, 2025
@fmease fmease added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. S-blocked Status: Blocked on something else such as an RFC or other implementation work. A-rustdoc-json Area: Rustdoc JSON backend labels May 21, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 21, 2025
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 21, 2025
@fmease fmease changed the title rustdoc: Clean AST + JSON: Yeet WherePredicate::EqPredicate rustdoc: Clean AST + JSON types: Yeet WherePredicate::EqPredicate May 21, 2025
@fmease
Copy link
Member Author

fmease commented May 21, 2025

The rustdoc JSON part came up here: #t-rustdoc > documenting rustdoc-json-types @ 💬 (and following!) back in 2024.

@fmease
Copy link
Member Author

fmease commented May 21, 2025

(I consider the rustdoc JSON subissue to be blocking the stabilization of rustdoc JSON which is but a theoretical concern at this point in time obviously)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants