trait A<'self_>: 'self_ {
type I;
}
trait AMut
where
Self: for<'self_> A<'self_>,
for<'self_> <Self as A<'self_>>::I: 'static,
{
fn mutate_self(&mut self);
}
fn foo<X>(x: &mut X)
where
X: 'static + for<'a> A<'a> + AMut,
for<'a> <X as A<'a>>::I: 'static,
{
x.mutate_self();
}
Playground
This errors out with
error[E0280]: the requirement `for<'self_> <Self as A<'self_>>::I: 'static` is not satisfied
--> src/lib.rs:4:1
|
4 | trait AMut
| ^ ---- required by a bound in this
| _|
| |
5 | | where
6 | | Self: for<'self_> A<'self_>,
7 | | for<'self_> <Self as A<'self_>>::I: 'static,
| | ------- required by this bound in `AMut`
8 | | {
9 | | fn mutate_self(&mut self);
10 | | }
| |_^
error[E0280]: the requirement `for<'self_> <X as A<'self_>>::I: 'static` is not satisfied
--> src/lib.rs:14:34
|
4 | trait AMut
| ---- required by a bound in this
...
7 | for<'self_> <Self as A<'self_>>::I: 'static,
| ------- required by this bound in `AMut`
...
14 | X: 'static + for<'a> A<'a> + AMut,
| ^^^^
I would've thought that the bound on line 15 would satisfy the bound on line 7. What am I missing?
question from:
https://stackoverflow.com/questions/34114048/why-cant-this-higher-kinded-lifetime-associated-type-trait-bound-be-satisfied 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…