@@ -9,7 +9,7 @@ use alloc::sync::Arc;
9
9
10
10
use slog:: { Logger , o} ;
11
11
12
- use zerogc:: { Gc , GcSafe , GcSystem , Trace , GcSimpleAlloc , NullTrace , TraceImmutable , GcVisitor , GcArray } ;
12
+ use zerogc:: { Gc , GcSafe , GcSystem , Trace , GcSimpleAlloc , NullTrace , TraceImmutable , GcVisitor , GcArray , TrustedDrop } ;
13
13
14
14
use crate :: { CollectorContext } ;
15
15
use crate :: state:: { CollectionManager , RawContext } ;
@@ -37,7 +37,7 @@ pub unsafe trait RawCollectorImpl: 'static + Sized {
37
37
/// The context
38
38
type RawContext : RawContext < Self > ;
39
39
/// The raw representation of a vec
40
- type RawVecRepr : GcVecRepr ;
40
+ type RawVecRepr < ' gc > : GcVecRepr < ' gc , Id = CollectorId < Self > > ;
41
41
42
42
/// True if this collector is a singleton
43
43
///
@@ -49,13 +49,13 @@ pub unsafe trait RawCollectorImpl: 'static + Sized {
49
49
const SYNC : bool ;
50
50
51
51
fn id_for_gc < ' a , ' gc , T > ( gc : & ' a Gc < ' gc , T , CollectorId < Self > > ) -> & ' a CollectorId < Self >
52
- where ' gc : ' a , T : GcSafe + ?Sized + ' gc ;
52
+ where ' gc : ' a , T : GcSafe < ' gc , CollectorId < Self > > + ?Sized + ' gc ;
53
53
54
54
fn id_for_array < ' a , ' gc , T > ( gc : & ' a GcArray < ' gc , T , CollectorId < Self > > ) -> & ' a CollectorId < Self >
55
- where ' gc : ' a , T : GcSafe + ' gc ;
55
+ where ' gc : ' a , T : GcSafe < ' gc , CollectorId < Self > > + ' gc ;
56
56
57
57
fn resolve_array_len < ' gc , T > ( gc : GcArray < ' gc , T , CollectorId < Self > > ) -> usize
58
- where T : GcSafe + ' gc ;
58
+ where T : GcSafe < ' gc , CollectorId < Self > > + ' gc ;
59
59
60
60
/// Convert the specified value into a dyn pointer
61
61
unsafe fn as_dyn_trace_pointer < T : Trace > ( t : * mut T ) -> Self :: DynTracePtr ;
@@ -74,7 +74,7 @@ pub unsafe trait RawCollectorImpl: 'static + Sized {
74
74
owner : & Gc < ' gc , O , CollectorId < Self > > ,
75
75
value : & Gc < ' gc , V , CollectorId < Self > > ,
76
76
field_offset : usize
77
- ) where O : GcSafe + ?Sized + ' gc , V : GcSafe + ?Sized + ' gc ;
77
+ ) where O : GcSafe < ' gc , CollectorId < Self > > + ?Sized + ' gc , V : GcSafe < ' gc , CollectorId < Self > > + ?Sized + ' gc ;
78
78
/// The logger associated with this collector
79
79
fn logger ( & self ) -> & Logger ;
80
80
@@ -283,20 +283,20 @@ impl<C: RawCollectorImpl> CollectorId<C> {
283
283
}
284
284
unsafe impl < C : RawCollectorImpl > :: zerogc:: CollectorId for CollectorId < C > {
285
285
type System = CollectorRef < C > ;
286
- type RawVecRepr = C :: RawVecRepr ;
286
+ type RawVecRepr < ' gc > = C :: RawVecRepr < ' gc > ;
287
287
288
288
#[ inline]
289
- fn from_gc_ptr < ' a , ' gc , T > ( gc : & ' a Gc < ' gc , T , Self > ) -> & ' a Self where T : GcSafe + ?Sized + ' gc , ' gc : ' a {
289
+ fn from_gc_ptr < ' a , ' gc , T > ( gc : & ' a Gc < ' gc , T , Self > ) -> & ' a Self where T : GcSafe < ' gc , Self > + ?Sized + ' gc , ' gc : ' a {
290
290
C :: id_for_gc ( gc)
291
291
}
292
292
293
293
#[ inline]
294
- fn resolve_array_len < ' gc , T > ( gc : GcArray < ' gc , T , Self > ) -> usize where T : GcSafe + ' gc {
294
+ fn resolve_array_len < ' gc , T > ( gc : GcArray < ' gc , T , Self > ) -> usize where T : GcSafe < ' gc , Self > + ' gc {
295
295
C :: resolve_array_len ( gc)
296
296
}
297
297
298
298
#[ inline]
299
- fn resolve_array_id < ' a , ' gc , T > ( gc : & ' a GcArray < ' gc , T , Self > ) -> & ' a Self where T : GcSafe + ' gc , ' gc : ' a {
299
+ fn resolve_array_id < ' a , ' gc , T > ( gc : & ' a GcArray < ' gc , T , Self > ) -> & ' a Self where T : GcSafe < ' gc , Self > + ' gc , ' gc : ' a {
300
300
C :: id_for_array ( gc)
301
301
}
302
302
@@ -306,7 +306,7 @@ unsafe impl<C: RawCollectorImpl> ::zerogc::CollectorId for CollectorId<C> {
306
306
owner : & Gc < ' gc , O , Self > ,
307
307
value : & Gc < ' gc , V , Self > ,
308
308
field_offset : usize
309
- ) where O : GcSafe + ?Sized + ' gc , V : GcSafe + ?Sized + ' gc {
309
+ ) where O : GcSafe < ' gc , Self > + ?Sized + ' gc , V : GcSafe < ' gc , Self > + ?Sized + ' gc {
310
310
C :: gc_write_barrier ( owner, value, field_offset)
311
311
}
312
312
@@ -320,6 +320,7 @@ unsafe impl<C: RawCollectorImpl> ::zerogc::CollectorId for CollectorId<C> {
320
320
& * ( self as * const CollectorId < C > as * const CollectorRef < C > )
321
321
}
322
322
}
323
+ unsafe impl < ' gc , OtherId : zerogc:: CollectorId , C : RawCollectorImpl > GcSafe < ' gc , OtherId > for CollectorId < C > { }
323
324
unsafe impl < C : RawCollectorImpl > Trace for CollectorId < C > {
324
325
const NEEDS_TRACE : bool = false ;
325
326
const NEEDS_DROP : bool = false ;
@@ -329,11 +330,12 @@ unsafe impl<C: RawCollectorImpl> Trace for CollectorId<C> {
329
330
}
330
331
331
332
#[ inline]
332
- unsafe fn visit_inside_gc < ' gc , V , Id > ( gc : & mut Gc < ' gc , Self , Id > , visitor : & mut V ) -> Result < ( ) , V :: Err > where V : GcVisitor , Id : zerogc:: CollectorId , Self : GcSafe + ' gc {
333
+ unsafe fn visit_inside_gc < ' gc , V , Id > ( gc : & mut Gc < ' gc , Self , Id > , visitor : & mut V ) -> Result < ( ) , V :: Err > where V : GcVisitor , Id : zerogc:: CollectorId , Self : GcSafe < ' gc , Id > {
333
334
// Fine to stuff inside a pointer. We're a regular 'Sized' type
334
335
visitor. visit_gc ( gc)
335
336
}
336
337
}
338
+ unsafe impl < C : RawCollectorImpl > TrustedDrop for CollectorId < C > { }
337
339
unsafe impl < C : RawCollectorImpl > TraceImmutable for CollectorId < C > {
338
340
#[ inline( always) ]
339
341
fn visit_immutable < V : GcVisitor > ( & self , _visitor : & mut V ) -> Result < ( ) , <V as GcVisitor >:: Err > {
@@ -363,35 +365,35 @@ impl<C: RawCollectorImpl> WeakCollectorRef<C> {
363
365
}
364
366
365
367
pub unsafe trait RawSimpleAlloc : RawCollectorImpl {
366
- unsafe fn alloc_uninit < ' gc , T : GcSafe + ' gc > ( context : & ' gc CollectorContext < Self > ) -> ( CollectorId < Self > , * mut T ) ;
368
+ unsafe fn alloc_uninit < ' gc , T : GcSafe < ' gc , CollectorId < Self > > > ( context : & ' gc CollectorContext < Self > ) -> ( CollectorId < Self > , * mut T ) ;
367
369
unsafe fn alloc_uninit_slice < ' gc , T > ( context : & ' gc CollectorContext < Self > , len : usize ) -> ( CollectorId < Self > , * mut T )
368
- where T : GcSafe + ' gc ;
370
+ where T : GcSafe < ' gc , CollectorId < Self > > ;
369
371
fn alloc_vec < ' gc , T > ( context : & ' gc CollectorContext < Self > ) -> GcVec < ' gc , T , CollectorContext < Self > >
370
- where T : GcSafe + ' gc ;
372
+ where T : GcSafe < ' gc , CollectorId < Self > > ;
371
373
fn alloc_vec_with_capacity < ' gc , T > ( context : & ' gc CollectorContext < Self > , capacity : usize ) -> GcVec < ' gc , T , CollectorContext < Self > >
372
- where T : GcSafe + ' gc ;
374
+ where T : GcSafe < ' gc , CollectorId < Self > > ;
373
375
}
374
376
unsafe impl < C > GcSimpleAlloc for CollectorContext < C >
375
377
where C : RawSimpleAlloc {
376
378
#[ inline]
377
379
unsafe fn alloc_uninit < ' gc , T > ( & ' gc self ) -> ( CollectorId < C > , * mut T )
378
- where T : GcSafe + ' gc {
380
+ where T : GcSafe < ' gc , CollectorId < C > > + ' gc {
379
381
C :: alloc_uninit ( self )
380
382
}
381
383
382
384
#[ inline]
383
385
unsafe fn alloc_uninit_slice < ' gc , T > ( & ' gc self , len : usize ) -> ( Self :: Id , * mut T )
384
- where T : GcSafe + ' gc {
386
+ where T : GcSafe < ' gc , CollectorId < C > > + ' gc {
385
387
C :: alloc_uninit_slice ( self , len)
386
388
}
387
389
388
390
#[ inline]
389
- fn alloc_vec < ' gc , T > ( & ' gc self ) -> GcVec < ' gc , T , Self > where T : GcSafe + ' gc {
391
+ fn alloc_vec < ' gc , T > ( & ' gc self ) -> GcVec < ' gc , T , Self > where T : GcSafe < ' gc , CollectorId < C > > + ' gc {
390
392
C :: alloc_vec ( self )
391
393
}
392
394
393
395
#[ inline]
394
- fn alloc_vec_with_capacity < ' gc , T > ( & ' gc self , capacity : usize ) -> GcVec < ' gc , T , Self > where T : GcSafe + ' gc {
396
+ fn alloc_vec_with_capacity < ' gc , T > ( & ' gc self , capacity : usize ) -> GcVec < ' gc , T , Self > where T : GcSafe < ' gc , CollectorId < C > > + ' gc {
395
397
C :: alloc_vec_with_capacity ( self , capacity)
396
398
}
397
399
}
0 commit comments