diff options
| author | bors <bors@rust-lang.org> | 2017-11-15 22:47:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-15 22:47:54 +0000 |
| commit | b8c70b0fdf7dea9bfd1834e61d32fc40f0c70db4 (patch) | |
| tree | 74888938d7fc3c771fceebf683acf2a7c7a1dcf8 /src/rustllvm/PassWrapper.cpp | |
| parent | fa26421f56e385b1055e65b29a55b36bb2eae23e (diff) | |
| parent | 4ce61b73620ade330bbafc3c6d56a0447bac2ca3 (diff) | |
| download | rust-b8c70b0fdf7dea9bfd1834e61d32fc40f0c70db4.tar.gz rust-b8c70b0fdf7dea9bfd1834e61d32fc40f0c70db4.zip | |
Auto merge of #45918 - chrisvittal:impl-trait-pr, r=nikomatsakis
Implement `impl Trait` in argument position (RFC1951, Universal quantification)
Implements the remainder of #44721, part of #34511.
**Note**: This PR currently allows argument position `impl Trait` in trait functions. The machinery is there to prevent this if we want to, but it currently does not.
Rename `hir::TyImplTrait` to `hir::TyImplTraitExistential` and add `hir::TyImplTraitUniversal(DefId, TyParamBounds)`. The `DefId` is needed to extract the index of the parameter in `ast_ty_to_ty`.
Introduce an `ImplTraitContext` enum to lowering to keep track of the kind and allowedness of `impl Trait` in that position. This new argument is passed through many places, all ending up in `lower_ty`.
Modify `generics_of` and `explicit_predicates_of` to collect the `impl Trait` args into anonymous synthetic generic parameters and to extend the predicates with the appropriate bounds.
Add a comparison of the 'syntheticness' of type parameters, that is, prevent the following.
```rust
trait Foo {
fn foo(&self, &impl Debug);
}
impl Foo for Bar {
fn foo<U: Debug>(&self, x: &U) { ... }
}
```
And vice versa.
Incedentally, supress `unused type parameter` errors if the type being compared is already a `TyError`.
**TODO**: I have tried to annotate open questions with **FIXME**s. The most notable ones that haven't been resolved are the names of the `impl Trait` types and the questions surrounding the new `compare_synthetic_generics` method.
1. For now, the names used for `impl Trait` parameters are `keywords::Invalid.name()`. I would like them to be `impl ...` if possible, but I haven't figured out a way to do that yet.
2. For `compare_synthetic_generics` I have tried to outline the open questions in the [function itself](https://github.com/chrisvittal/rust/blob/3fc9e3705f7bd01f3cb0ea470cf2892f17a92350/src/librustc_typeck/check/compare_method.rs#L714-L725)
r? @nikomatsakis
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
