Skip to content

Commit

Permalink
gc: Fix a few clippy complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Jun 25, 2024
1 parent 156b090 commit e6c3f0c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where

impl<T: Trace> Clone for Gc<T> {
fn clone(&self) -> Self {
Self::node_mut(&self).increment_root_count();
Self::node_mut(self).increment_root_count();

Self {
// The new gc starts out on the stack
Expand Down Expand Up @@ -65,12 +65,10 @@ where
// since allocating the node might trigger a garbage collection.
unsafe { node.as_ref() }.value().unroot();

let gc = Self {
Self {
is_rooted: Cell::new(true),
referenced_node: Cell::new(node),
};

gc
}
}
}

Expand Down Expand Up @@ -123,13 +121,16 @@ where
value.is_rooted.set(false);
}

#[must_use]
pub fn node(value: &Self) -> &HeapNode<T> {
let raw_ptr = value.referenced_node.get();

// SAFETY: &self is a live reference, so the heap node is guaranteed to be alive
unsafe { raw_ptr.as_ref() }
}

#[allow(clippy::mut_from_ref)]
#[must_use]
pub fn node_mut(value: &Self) -> &mut HeapNode<T> {
let mut heap_node = value.referenced_node.get();

Expand Down

0 comments on commit e6c3f0c

Please sign in to comment.