-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccac43b
commit 9da3a7a
Showing
1 changed file
with
11 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
`impl Trait` types cannot appear nested in the | ||
generic arguments of other `impl Trait` types. | ||
`impl Trait` types cannot appear nested in the generic arguments of other | ||
`impl Trait` types. | ||
|
||
Example of erroneous code: | ||
Erroneous code example: | ||
|
||
```compile_fail,E0666 | ||
trait MyGenericTrait<T> {} | ||
trait MyInnerTrait {} | ||
fn foo(bar: impl MyGenericTrait<impl MyInnerTrait>) {} | ||
fn foo( | ||
bar: impl MyGenericTrait<impl MyInnerTrait>, // error! | ||
) {} | ||
``` | ||
|
||
Type parameters for `impl Trait` types must be | ||
explicitly defined as named generic parameters: | ||
Type parameters for `impl Trait` types must be explicitly defined as named | ||
generic parameters: | ||
|
||
``` | ||
trait MyGenericTrait<T> {} | ||
trait MyInnerTrait {} | ||
fn foo<T: MyInnerTrait>(bar: impl MyGenericTrait<T>) {} | ||
fn foo<T: MyInnerTrait>( | ||
bar: impl MyGenericTrait<T>, // ok! | ||
) {} | ||
``` |