kyren / gc-arena

Incremental garbage collection from safe Rust
Creative Commons Zero v1.0 Universal
438 stars 36 forks source link

Get rid of a bad footgun with `Collect` impls on `&T` #51

Closed kyren closed 1 year ago

kyren commented 1 year ago

The existing Collect impls on reference types are sound, but they're a huge footgun because it's easy to accidentally call <&T as Collect>::trace instead of T::trace.

Just remove them and have an impl only for &'static T. Now, if you accidentally try to call <&T as Collect>::trace, you will at least get a compiler error instead of a silent footgun.

moulins commented 1 year ago

LGTM; it would be best to pair this with a more powerful StaticCollect wrapper (e.g. implementing more traits), but this can wait for a future PR.