Why doesn't it compile:
trait Awesome {}
struct Foo<S>
where
for<'a> &'a mut S: Awesome,
{
s: S,
}
impl<S> Foo<S>
where
for<'a> &'a mut S: Awesome,
{
pub fn new(s: S) -> Foo<S> {
Foo { s }
}
}
impl<S> Awesome for &mut Foo<S> where for<'a> &'a mut S: Awesome {}
Error:
error[E0275]: overflow evaluating the requirement `for<'a> &'a mut Foo<_>: Awesome`
--> src/xxxxxxx.rs:15:9
|
15 | Foo { s }
| ^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`shadow_proxy`)
note: required for `&'a mut Foo<Foo<_>>` to implement `for<'a> Awesome`
--> src/xxxxx.rs:19:9
|
19 | impl<S> Awesome for &mut Foo<S> where for<'a> &'a mut S: Awesome {}
| ^^^^^^^ ^^^^^^^^^^^
= note: 127 redundant requirements hidden
= note: required for `&'a mut Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<Foo<_>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `for<'a> Awesome`
note: required by a bound in `Foo`
--> src/xxxxxx/:5:24
|
3 | struct Foo<S>
| --- required by a bound in this
4 | where
5 | for<'a> &'a mut S: Awesome,
| ^^^^^^^ required by this bound in `Foo`
For more information about this error, try `rustc --explain E0275`.
I don't understand why for evaluating if Foo<S>
is Awesome, it tries to evaluate if Foo<Foo<S>>
is awesome, when the constraint just says &mut S
should be Awesome....
Changing the constraints to something simpler like S: Awesome
makes the error go away. No idea why a reference makes a difference here.