Closed
Description
I tried this code:
#![recursion_limit="5"] // without it the error is the same, but much bigger
struct Nil;
struct Cons<H, T>(H, T);
pub trait Map<F> {
type Output;
}
impl<FH, FM, FT, H, M, T, R> Map<Cons<FH, Cons<FM, FT>>> for Cons<H, Cons<M, T>>
where
FH: FnOnce(H) -> R,
Cons<M, T>: Map<Cons<FM, FT>>,
{
type Output = Cons<R, <Cons<M, T> as Map<Cons<FM, FT>>>::Output>;
}
impl<F, H, T, R> Map<F> for Cons<H, T>
where
F: FnMut(H) -> R,
T: Map<F>,
{
type Output = Cons<R, T::Output>;
}
I expected this code to compile.
Instead, the compiler fails with a huge error:
error[E0275]: overflow evaluating the requirement `Cons<_, Cons<_, _>>: Map<Cons<_, Cons<_, _>>>`
|
= help: consider adding a `#![recursion_limit="10"]` attribute to your crate (`playground`)
= note: required because of the requirements on the impl of `Map<Cons<_, Cons<_, Cons<_, _>>>>` for `Cons<_, Cons<_, Cons<_, _>>>`
= note: required because of the requirements on the impl of `Map<Cons<_, Cons<_, Cons<_, Cons<_, _>>>>>` for `Cons<_, Cons<_, Cons<_, Cons<_, _>>>>`
= note: required because of the requirements on the impl of `Map<Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, _>>>>>>` for `Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, _>>>>>`
= note: required because of the requirements on the impl of `Map<Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, _>>>>>>>` for `Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, _>>>>>>`
= note: required because of the requirements on the impl of `Map<Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, _>>>>>>>>` for `Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, Cons<_, _>>>>>>>`
Note that very similar code with a slightly different trait works, so I assume this is a bug (though, I may miss something)
Also, note that there is a lot of issues with E0275
, however, I couldn't find one that fits my problem.
Meta
Tested on 1.45.0
and 1.47.0-nightly (2020-07-25 d6953df14657f5932270)