diff --git a/src/clox/mm.rs b/src/clox/mm.rs index 455da9a..1c368cf 100644 --- a/src/clox/mm.rs +++ b/src/clox/mm.rs @@ -301,7 +301,11 @@ impl WeakRoot { // Slot is already taken return None; } - self.0.set(NonNull::new(root as *mut _)); + self.0.set(NonNull::new(unsafe { + std::mem::transmute::<*const (dyn HasRoots + 'root), *mut (dyn HasRoots + 'static)>( + root, + ) + })); Some(GcToken(self, PhantomData)) }