]> git.lizzy.rs Git - rust.git/commit
Properly use parent generics for opaque types
authorAaron Hill <aa1ronham@gmail.com>
Sun, 9 Feb 2020 23:38:21 +0000 (18:38 -0500)
committerAaron Hill <aa1ronham@gmail.com>
Sun, 9 Feb 2020 23:45:12 +0000 (18:45 -0500)
commita60669d95cdad0e28cf28790b717bbcf235153f8
treec7fea4103952ea5385912f4ce5d7884f2d998e97
parent71c7e149e42cb0fc78a80db70d2525973311d488
Properly use parent generics for opaque types

Fixes #67844

Previously, opaque types would only get parent generics if they
a return-position-impl-trait (e.g. `fn foo<A>() -> impl MyTrait<A>`).

However, it's possible for opaque types to be nested inside one another:

```rust
trait WithAssoc { type AssocType; }

trait WithParam<A> {}

type Return<A> = impl WithAssoc<AssocType = impl WithParam<A>>;
```

When this occurs, we need to ensure that the nested opaque types
properly inherit generic parameters from their parent opaque type.

This commit fixes the `generics_of` query to take the parent item
into account when determining the generics for an opaque type.
src/librustc_typeck/collect.rs
src/test/ui/type-alias-impl-trait/issue-67844-nested-opaque.rs [new file with mode: 0644]