rust-lang / types-team

Home of the "types team", affiliated with the compiler and lang teams.
https://rust-lang.github.io/types-team/
Apache License 2.0
94 stars 19 forks source link

Add experimental support for `for<T>` binders in limited positions #81

Closed compiler-errors closed 1 year ago

compiler-errors commented 1 year ago

Proposal

Modify the resolver and type system to support for<T> in where clauses and associated item bounds (not object types or return-position impl traits).

Why?

  1. They should eventually also be useful for things like where clauses involving GATs (e.g. where for<T> Self::Assoc<T>: Trait).
  2. This will allow us to test out ty::Bound and ty::Placeholder a bit more, even if currently they're pretty useless on their own (i.e. without implication predicates).
  3. They should eventually work synergistically with implication predicates, if or when we add support for those (e.g. where for<T: Debug> Self::Assoc<T>: Debug).

Side-note: If anyone thinks this should be a compiler MCP, I'd be happy to move this over there. If this is better suited for a T-lang initiative, or needs a pre-RFC, then let me know.

Mentors or Reviewers

I've got a branch that mostly implements support for this, but it needs major cleaning up. I'm willing to do that work, but I just don't want to invest too much time to clean it up unless there's reasonable interest in support for type binders from other team members. https://github.com/rust-lang/rust/compare/master...compiler-errors:rust:non_lifetime_binders

Process

The main points of the Major Change Process are as follows:

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

rustbot commented 1 year ago

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/types

jackh726 commented 1 year ago

@rustbot second

The actual PR for this will likely need lang okay, but from a types perspective, I think it's a good feature to experiment with.

compiler-errors commented 1 year ago

Cool, noted

zyansheep commented 1 year ago

Would this addition resolve https://github.com/rust-lang/rfcs/issues/1481 ?

compiler-errors commented 1 year ago

@zyansheep, yes

lcnr commented 1 year ago

closing as accepted