April 22, 2026
Garbage day, drama play
Garbage Collection Without Unsafe Code
Rust dev drops “no-unsafe” garbage collector and the comments go nuclear
TLDR: A developer released safe-gc, a Rust garbage collector that uses zero “unsafe” code, proving it’s possible—even if slower and clunkier. Commenters split: some applaud the safety milestone, others groan about rewrites and usability, while skeptics argue this won’t magically fix Rust’s bigger pain points. Why it matters: safer tools shape future Rust design.
Rust just got a new experiment: a garbage collector that bans the scary “unsafe” switch entirely. It’s called safe-gc, and the creator even slapped a “forbid unsafe code” sign on the door. Translation for non‑Rust folks: it manages memory without touching the risky back‑doors many libraries quietly rely on. Cool twist? It works—but it’s not built for speed, and you have to access everything through a manager (a “Heap”) instead of poking objects directly. The crowd? Split in spectacular fashion. Fans like swiftcoder are calling it a neat proof‑of‑concept: proof you can keep the training wheels on and still ride. But the ergonomics police showed up fast. the‑smug‑one grumbled that wrapping everything in special GC pointers ties your types to this allocator and makes trying it out a rewrite headache. Another dev, foota, popped in from the land of C integrations to say “interesting, but not for me,” sticking with homegrown pointer checks instead. Then the spicy takes hit. rurban rolled in with a sarcastic “memory‑safe at last” and a link to known Rust bug reports, hinting that banning one sharp edge doesn’t make the whole kitchen safe. Meanwhile, ltratt basically begged for a scoreboard, because Rust now has more DIY collectors than anyone can track. The meme of the day: “forbid(unsafe_code)” as a forehead tattoo—bold, a little extra, and guaranteed to start a fight.
Key Points
- •safe-gc is a Rust garbage collection library implemented with zero unsafe code, enforced by forbid(unsafe_code).
- •Unlike prior Rust GC libraries, safe-gc’s edge enumeration trait (Trace) is safe to implement.
- •Users define GC-managed types using Gc<T> fields and implement Trace to report edges via Collector.
- •Objects are allocated in Heap instances, which collect automatically and can be manually triggered with heap.gc().
- •Access to GC-managed objects is via heap indexing (heap[&gc]) rather than direct dereference, enabling soundness under Rust’s borrowing rules.