Skip to content

Commit

Permalink
Clean up E0666 explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 11, 2020
1 parent ccac43b commit 9da3a7a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/librustc_error_codes/error_codes/E0666.md
@@ -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!
) {}
```

0 comments on commit 9da3a7a

Please sign in to comment.