Compiler hangs, looking for workaround

This code (specifically the Clone impl) makes the compiler hang indefinitely: Rust Playground

I've also tried implementing Clone manually, with the same result. (In fact, I'd rather have a bound on the impl than on the associated type.) I'd also be OK with an additional trait like pub trait CloneRel<V>: Rel<V, Eq: CloneRel<Self>>, but the compiler complains about a cycle in that case.

Any ideas for a workaround (that does not involve making V and E the same type)? Thanks.

Edit: If I delete the trait parameter, I get an error message instead of an infinite loop. That's better of course, but I wonder if it's possible to find a solution. I guess I could implement Clone for the concrete instances that come up, then.

I don't think the code is limited to clone. The structure is infinite recursive with generic types.

You can stop the hang by setting a lower than the 128 default but it does not make it compile.

#![recursion_limit = "20"]
2 Likes