Open
Description
I encountered a recursion overflow error on a trait implementation of HashMap (Encodable
) when I tried to extend an unrelated trait (Inner
) by a where clause for the same trait. This might end in a case of 'You are holding it wrong', but I couldn't find any clue why the change should infer with the given implementation:
Minimal Example
use std::collections::HashMap;
pub trait Encodable {}
pub trait Inner
where
for<'a> &'a Self: Encodable,
{
}
pub trait Outer {
type Inner: Inner;
}
impl<'a, K, V, S> Encodable for &'a HashMap<K, V, S>
where
&'a V: Encodable,
{
}
Error Log
Compiling playground v0.0.1 (file:///playground)
error[E0275]: overflow evaluating the requirement `_: std::marker::Sized`
|
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
= note: required because of the requirements on the impl of `for<'a> Encodable` for `&'a std::collections::HashMap<_, _, _>`
= note: required because of the requirements on the impl of `for<'a> Encodable` for `&'a std::collections::HashMap<_, std::collections::HashMap<_, _, _>, _>`
= note: required because of the requirements on the impl of `for<'a> Encodable` for `&'a std::collections::HashMap<_, std::collections::HashMap<_, std::collections::HashMap<_, _, _>, _>, _>`
= note: required because of the requirements on the impl of `for<'a> Encodable` for `&'a std::collections::HashMap<_, std::collections::HashMap<_, std::collections::HashMap<_, std::collections::HashMap<_, _, _>, _>, _>, _>`
= note: required because of the requirements on the impl of `for<'a> Encodable` for `&'a std::collections::HashMap<_, std::collections::HashMap<_, std::collections::HashMap<_, std::collections::HashMap<_, std::collections::HashMap<_, _, _>, _>, _>, _>, _>`
[...]
Reproduced with: