Skip to content
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

🚀 create a query for the program clauses needed to solve a given goal #49600

Closed
nikomatsakis opened this issue Apr 2, 2018 · 1 comment
Closed
Assignees
Labels
A-traits Area: Trait system C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Apr 2, 2018

One of the key parts of the interface between the Chalk Solver and rustc is when the solver requests the program clauses to solve a given goal:

    /// Returns the set of program clauses that might apply to
    /// `goal`. (This set can be over-approximated, naturally.)
    fn program_clauses(
        &self,
        environment: &I::Environment,
        goal: &I::DomainGoal,
    ) -> Vec<I::ProgramClause>;

In Rustc, this is our chance to do some queries and figure out the full set of clauses. This is building on the work in #49177, where we create the lowering rules for a trait, item, etc (see also the rustc guide coverage).

The set of clauses is somewhat specific to the domain goal:

  • Implemented(P0: Trait<...>)
  • FromEnv(P0: Trait<..>)
    • these come -- ultimately -- from the param environment
    • but because of implied bounds rules we need to combine with the rules from traits
    • we need to compute transitive closure of traits reachable from the env and combine their program clauses, or else iterate over "all traits" (which is actually not easy)
    • I have some code working towards this on my WIP branch for this issue
  • ... the rest have to be written out :)

I'll probably keep iterating on this, but if somebody is keen to hack on it, I'd love to collaborate.

@nikomatsakis nikomatsakis added A-traits Area: Trait system WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 labels Apr 2, 2018
@XAMPPRocky XAMPPRocky added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Jun 29, 2018
@scalexm
Copy link
Member

scalexm commented Nov 15, 2018

Implemented in #55203 and #55649.

@scalexm scalexm closed this as completed Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804
Projects
None yet
Development

No branches or pull requests

3 participants