|
| 1 | +#![feature( |
| 2 | + arbitrary_self_types, // Used for `zerogc(mutable)` |
| 3 | +)] |
1 | 4 | use zerogc::{Gc, CollectorId, Trace, GcSafe, NullTrace, dummy_impl::{self, DummyCollectorId}}; |
2 | 5 |
|
3 | 6 | use zerogc_derive::{Trace, NullTrace}; |
| 7 | +use zerogc::cell::GcCell; |
4 | 8 |
|
5 | 9 | #[derive(Trace)] |
6 | 10 | #[zerogc(collector_id(DummyCollectorId))] |
7 | 11 | pub struct SpecificCollector<'gc> { |
8 | 12 | gc: Gc<'gc, i32, DummyCollectorId>, |
9 | | - rec: Gc<'gc, SpecificCollector<'gc>, DummyCollectorId> |
| 13 | + rec: Gc<'gc, SpecificCollector<'gc>, DummyCollectorId>, |
| 14 | + #[zerogc(mutable)] |
| 15 | + cell: GcCell<Gc<'gc, SpecificCollector<'gc>, DummyCollectorId>> |
10 | 16 | } |
11 | 17 |
|
12 | 18 | #[derive(Trace)] |
13 | 19 | #[zerogc(collector_id(Id))] |
14 | 20 | pub struct Basic<'gc, Id: CollectorId> { |
15 | 21 | parent: Option<Gc<'gc, Basic<'gc, Id>, Id>>, |
16 | 22 | children: Vec<Gc<'gc, Basic<'gc, Id>, Id>>, |
17 | | - value: String |
| 23 | + value: String, |
| 24 | + #[zerogc(mutable)] |
| 25 | + cell: GcCell<Option<Gc<'gc, Basic<'gc, Id>, Id>>> |
18 | 26 | } |
19 | 27 |
|
20 | 28 | #[derive(Copy, Clone, Trace)] |
@@ -110,7 +118,8 @@ fn basic<'gc>() { |
110 | 118 | let _b = Basic::<dummy_impl::DummyCollectorId> { |
111 | 119 | value: String::new(), |
112 | 120 | parent: None, |
113 | | - children: vec![] |
| 121 | + children: vec![], |
| 122 | + cell: GcCell::new(None) |
114 | 123 | }; |
115 | 124 | assert!(<Basic::<dummy_impl::DummyCollectorId> as Trace>::NEEDS_TRACE); |
116 | 125 | assert!(<BasicCopy::<dummy_impl::DummyCollectorId> as Trace>::NEEDS_TRACE); |
|
0 commit comments