-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #593 - Aaron1011:feature/generators, r=nikomatsakis
Implement generators `GeneratorDatum` and `GeneratorWitnessDatum` are introduced, which mirror `TyKind::Generator` and `TyKind::GeneratorWitness` in rustc. We handle auto traits for `GeneratorDatum` using the existing `constituent_types` method. For `GeneratorWitnessDatum`, we generate a `forall<'a, 'b, ... 'z>` goal to reflect the fact that our lifetimes are existentially bound. Unresolved questions: * The implementation of `GeneratorWitnessDatum` needs careful review - I'm not certain that I fully understand how `Binders` works. * The syntax implemented in `parser.lalrpop` can be bikesheeded. We might want to use something other than `for<>` for the witness types, to reflect that fact that we have existential rather than universal quantification. * The generator grammar only allows quantifying over liftimes for the witness types - however, this gets lowered to a `Binders`, which supports types and constants as well. Should we do anything else to ensure we never end up with types/consts where they're not expected? * I added a test to ensure that we treat the witness lifetimes as existentially quantified - for example, if we have `for<'a, 'b> Foo<'a, 'b>`, we should only be able to use an auto trait impl that is fully generic over lifetimes - e.g. `impl<'a> Send for Foo<'a, 'b>` will not be used. I *believe* that the test is showing this behavior - it ends up returning region constraints that require `'a` and `'b` to outlive each other. Since these are 'existential' lifetimes (which cannot be substituted), this is an unsatisfiable constraint. However, I'm not sure where we should be detecting that this is unsatisfiable. * In rustc, all of the existential witness lifetimes are distinct. This is not enforced by this PR e.g. you can repeat a lifetime in the witness type. I'm not sure if/where we should enforce this.
- Loading branch information
Showing
31 changed files
with
615 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.