Closed dragazo closed 1 year ago
I realize now that this basically just moves the problem to the first operation actually requiring T: Collect
. Still looking for a fix for that part - will close if nothing is found. At the very least, this fixes a related bug with deducing Copy
and Sized
for recursive types, though they still can't be allocated or mutated...
The more I look at it, the more it just seems like a shortcoming of rustc
. Maybe I can get a minimal version of basic traits causing this and submit an issue to the rustlang team.
Alternatively, I think it would fix the remaining issues if the derive macro could directly generate a compile error if it fails to derive rather than producing trait bounds: so basically assert that it's safe to implement and then do so unconditionally. The whole issue seems to revolve around infinite loops when checking trait bounds, so avoiding those would probably fix the issue, but I'm not knowledgeable enough in proc macros to know if that's possible.
Closes #21. It seems like the early requirement of
T: Collect
directly in the definition of several types (notablyGc
andGcCell
) was causing the rust compiler's trait bound satisfaction check to decay into infinite recursion for both direct and indirect recursive types. Simply removing this early requirement (on only the struct definitions) but keeping all the bounds on implementations solves the problem, and I believe doesn't impose any unsoundness since the struct does nothing on its own and all the implementators use (and need)Collect
on their own.