]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0666.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0666.md
1 `impl Trait` types cannot appear nested in the generic arguments of other
2 `impl Trait` types.
3
4 Erroneous code example:
5
6 ```compile_fail,E0666
7 trait MyGenericTrait<T> {}
8 trait MyInnerTrait {}
9
10 fn foo(
11     bar: impl MyGenericTrait<impl MyInnerTrait>, // error!
12 ) {}
13 ```
14
15 Type parameters for `impl Trait` types must be explicitly defined as named
16 generic parameters:
17
18 ```
19 trait MyGenericTrait<T> {}
20 trait MyInnerTrait {}
21
22 fn foo<T: MyInnerTrait>(
23     bar: impl MyGenericTrait<T>, // ok!
24 ) {}
25 ```