Skip to content

Separate clauses and goals from the Predicate type #107250

Description

@oli-obk

Split up the PredicateKind type into Goal and Clauses similar (or exactly :D) like what chalk does. The TLDR is that ParamEnv only contains a small set of PrecicateKind variants and we want to encode this in the type system by only returning Clauses from it.

This projection has been accepted as an MCP: rust-lang/compiler-team#531

Implementation steps

  • [SP] Split out Trait, TypeOutlives, RegionOutlives and Projection into Clause enum: #104846
  • [SP] #104911 inferred_outlives_crate returns predicates, but they are always only TypeOutlives or RegionOutlives
    • may kill perf, so let's see if it works to just return ty::Clause where it now returns ty::Predicate and build the predicates at the caller site of inferred_outlives_of
  • doing the same thing for explicit_predicates_of is gonna be a bit more involved
  • Improve perf of #104846
  • start with gather_explicit_predicates_of and convert at the caller sites
  • Bounds::predicates should return an iterator over Clauses (Make Bound::predicates use Clause #112734)

Follow-up work after #112938:

  • Investigate making TypeFoldable<TyCtxt<'tcx>> for ty::Clause<'tcx> implementation less weird:
    .expect("no sensible folder would do this"))
  • Clean up the elaborator since it should only be emitting child clauses, not predicates
  • Rename identifiers like pred and predicates to clause if they're actually clauses around the codebase
  • Validate that all of the ToPredicate impls are acutally still needed, or prune them if they're not

leave a comment when you start working on one of these steps so that no one else duplicates work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions