Skip to content

Commit e289ce8

Browse files
committed
Implement Trace for RefCell/Cell iff T: NullTrace
1 parent 6cecda4 commit e289ce8

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

src/manually_traced/core.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
//!
33
//! This includes references, tuples, primitives, arrays, and everything else in `libcore`.
44
//!
5-
//! `RefCell` and `Cell` are intentionally ignored and do not have implementations.
6-
//! Some collectors may need write barriers to protect their internals.
5+
//! `RefCell` and `Cell` require `T: NullTrace` and do not have implementations for other types.
6+
//! This is because some collectors may need write barriers to protect their internals.
77
use core::num::Wrapping;
88
use core::marker::PhantomData;
9+
use core::cell::{RefCell, Cell};
910

1011
use crate::prelude::*;
1112
use crate::GcDirectBarrier;
@@ -200,6 +201,40 @@ unsafe_gc_impl! {
200201
}
201202

202203

204+
unsafe_gc_impl!(
205+
target => Cell<T>,
206+
params => [T: NullTrace],
207+
bounds => {
208+
GcRebrand => { where T: NullTrace, T: 'new_gc },
209+
GcErase => { where T: NullTrace, T: 'min }
210+
},
211+
branded_type => Self,
212+
erased_type => Self,
213+
null_trace => always,
214+
NEEDS_TRACE => false,
215+
NEEDS_DROP => T::NEEDS_DROP,
216+
visit => |self, visitor| {
217+
Ok(()) /* nop */
218+
}
219+
);
220+
unsafe_gc_impl!(
221+
target => RefCell<T>,
222+
params => [T: NullTrace],
223+
bounds => {
224+
GcRebrand => { where T: NullTrace, T: 'new_gc },
225+
GcErase => { where T: NullTrace, T: 'min }
226+
},
227+
branded_type => Self,
228+
erased_type => Self,
229+
null_trace => always,
230+
NEEDS_TRACE => false,
231+
NEEDS_DROP => T::NEEDS_DROP,
232+
visit => |self, visitor| {
233+
Ok(()) /* nop */
234+
}
235+
);
236+
237+
203238
/*
204239
* Implements tracing for mutable references.
205240
*

0 commit comments

Comments
 (0)