W3cubDocs

/Rust

Error code E0666

impl Trait types cannot appear nested in the generic arguments of other impl Trait types.

Erroneous code example:

#![allow(unused)]
fn main() {
trait MyGenericTrait<T> {}
trait MyInnerTrait {}

fn foo(
    bar: impl MyGenericTrait<impl MyInnerTrait>, // error!
) {}
}

Type parameters for impl Trait types must be explicitly defined as named generic parameters:

#![allow(unused)]
fn main() {
trait MyGenericTrait<T> {}
trait MyInnerTrait {}

fn foo<T: MyInnerTrait>(
    bar: impl MyGenericTrait<T>, // ok!
) {}
}

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/error_codes/E0666.html