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)
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
WaffleLapkin commentedon Jul 26, 2020
I've created more minimal example:
(playground)
I don't expect this to compile (in difference with original example), though the error should definitely be
instead of
RodBurman commentedon Feb 12, 2025
The current tool chain:
compiles the original code with just a warning:
So no overflow or other error, I think this issue can be closed.
WaffleLapkin commentedon Feb 15, 2025
Indeed, the issue seems to be fixed. Still, it'd be interesting to see which PR fixed the issue, and add test(s) in case the PR which fixed this did not have similar tests already. Tagging this issue appropriately.
moxian commentedon Mar 25, 2025
Bisects to #130654
I believe there is appropriate test coverage in that PR as well, but I might be misreading this.
@rustbot label: -E-needs-bisection +S-has-bisection +A-coherence
2 remaining items