Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: HRTBs bound GAT output E0477
trait Foo<T> {}
impl Foo<()> for () { }
trait Slice {
type Elem;
type Query<'a> where Self::Elem: 'a, Self: 'a;
fn query<F>(&mut self, f: F) -> bool
where
F: for<'a> Foo<Self::Query<'a>>;
}
impl<T> Slice for [T] {
type Elem = T;
type Query<'a> = () where T: 'a;
fn query<F>(&mut self, _: F) -> bool
where
F: for<'a> Foo<()>, // yes
{
todo!()
}
}
impl<S: Slice> Slice for &mut S {
type Elem = S::Elem;
type Query<'a> = S::Query<'a> where S::Elem: 'a, Self: 'a;
fn query<F>(&mut self, f: F) -> bool
where
F: for<'a> Foo<Self::Query<'a>>, // oh no!
{
(**self).query(f)
}
}
outputs:
Compiling test_ v0.1.0 (/home/lrne/Project/Rust/test_)
error[E0477]: the type `&mut S` does not fulfill the required lifetime
--> src/main.rs:3060:12
|
3060 | F: for<'a> Foo<Self::Query<'a>>, // oh no!
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0477]: the type `&mut S` does not fulfill the required lifetime
--> src/main.rs:3058:8
|
3058 | fn query<F>(&mut self, f: F) -> bool
| ^^^^^
For more information about this error, try `rustc --explain E0477`.
error: could not compile `test_` (bin "test_") due to 2 previous errors
2 posts - 2 participants
🏷️ rust_feed