An impl Trait captured a higher-ranked lifetime, which is not supported.
Currently, impl Trait types are only allowed to capture lifetimes from their parent items, and not from any for<'a> binders in scope.
Erroneous code example:
#![allow(unused)]
fn main() {
trait BorrowInto<'a> {
type Target;
fn borrow_into(&'a self) -> Self::Target;
}
impl<'a> BorrowInto<'a> for () {
type Target = &'a ();
fn borrow_into(&'a self) -> Self::Target {
self
}
}
fn opaque() -> impl for<'a> BorrowInto<'a, Target = impl Sized + 'a> {
()
}
}
© 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/E0657.html