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

Re-think the WhereClauseAtom abstraction #115

Closed
scalexm opened this issue May 1, 2018 · 1 comment
Closed

Re-think the WhereClauseAtom abstraction #115

scalexm opened this issue May 1, 2018 · 1 comment

Comments

@scalexm
Copy link
Member

scalexm commented May 1, 2018

After GATs are implemented and if everything goes well, we won't need WellFormed(WhereClauseAtom::ProjectionEq) abstraction, defeating the initial purpose of the WhereClauseAtom abstraction.

I propose that we instead re-use WhereClauseAtom to include every where clause that can effectively be written by a Rust programmer, e.g. it should include:

  • Implemented(T: Foo)
  • ProjectionEq(<T as Foo>::Item = U)
  • T: 'a (not implemented for the moment)
  • 'a: 'b

Then, the various IR constructs which represent real rust code like:
https://github.com/rust-lang-nursery/chalk/blob/eeb21829c1e847921261ad820b5b2ec35b649c76/src/ir/mod.rs#L202-L207
should carry where clauses of the type Binders<WhereClauseAtom> (which could be aliased into QuantifiedWhereClauseAtom) instead of the current type QuantifiedDomainGoal.

This will enable rewriting some match blocks where we used to do things like:

WellFormed(..) | ... | => panic!("unexepected"),

or

WellFormed(..) | ... | => (),

e.g. like in
https://github.com/rust-lang-nursery/chalk/blob/eeb21829c1e847921261ad820b5b2ec35b649c76/src/lower/wf.rs#L131-L147

Bikeshedding: we could also just use the name WhereClause instead of WhereClauseAtom, like in the old days.

Another question left open: should we merge the current WellFormed / FromEnv predicate -- which would then deal only with trait references -- with WellFormedTy / FromEnvTy?

cc @rust-lang-nursery/wg-traits

@scalexm scalexm mentioned this issue May 1, 2018
@scalexm
Copy link
Member Author

scalexm commented May 10, 2018

Also when this is done we'll be able to clean up the grammar a bit, and support inline bounds (e.g. imp<K, T: Foo<K>> SomeType<T>) in a clean way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant