@@ -114,10 +114,9 @@ impl<T> TypedArenaChunk<T> {
114114
115115const PAGE : usize = 4096 ;
116116
117- impl < T > TypedArena < T > {
117+ impl < T > Default for TypedArena < T > {
118118 /// Creates a new `TypedArena`.
119- #[ inline]
120- pub fn new ( ) -> TypedArena < T > {
119+ fn default ( ) -> TypedArena < T > {
121120 TypedArena {
122121 // We set both `ptr` and `end` to 0 so that the first call to
123122 // alloc() will trigger a grow().
@@ -127,7 +126,9 @@ impl<T> TypedArena<T> {
127126 _own : PhantomData ,
128127 }
129128 }
129+ }
130130
131+ impl < T > TypedArena < T > {
131132 /// Allocates an object in the `TypedArena`, returning a reference to it.
132133 #[ inline]
133134 pub fn alloc ( & self , object : T ) -> & mut T {
@@ -296,15 +297,17 @@ pub struct DroplessArena {
296297
297298unsafe impl Send for DroplessArena { }
298299
299- impl DroplessArena {
300- pub fn new ( ) -> DroplessArena {
300+ impl Default for DroplessArena {
301+ fn default ( ) -> DroplessArena {
301302 DroplessArena {
302303 ptr : Cell :: new ( 0 as * mut u8 ) ,
303304 end : Cell :: new ( 0 as * mut u8 ) ,
304- chunks : RefCell :: new ( vec ! [ ] ) ,
305+ chunks : Default :: default ( ) ,
305306 }
306307 }
308+ }
307309
310+ impl DroplessArena {
308311 pub fn in_arena < T : ?Sized > ( & self , ptr : * const T ) -> bool {
309312 let ptr = ptr as * const u8 as * mut u8 ;
310313 for chunk in & * self . chunks . borrow ( ) {
@@ -419,18 +422,13 @@ impl DroplessArena {
419422 }
420423}
421424
425+ #[ derive( Default ) ]
426+ // FIXME(@Zoxc): this type is entirely unused in rustc
422427pub struct SyncTypedArena < T > {
423428 lock : MTLock < TypedArena < T > > ,
424429}
425430
426431impl < T > SyncTypedArena < T > {
427- #[ inline( always) ]
428- pub fn new ( ) -> SyncTypedArena < T > {
429- SyncTypedArena {
430- lock : MTLock :: new ( TypedArena :: new ( ) )
431- }
432- }
433-
434432 #[ inline( always) ]
435433 pub fn alloc ( & self , object : T ) -> & mut T {
436434 // Extend the lifetime of the result since it's limited to the lock guard
@@ -452,18 +450,12 @@ impl<T> SyncTypedArena<T> {
452450 }
453451}
454452
453+ #[ derive( Default ) ]
455454pub struct SyncDroplessArena {
456455 lock : MTLock < DroplessArena > ,
457456}
458457
459458impl SyncDroplessArena {
460- #[ inline( always) ]
461- pub fn new ( ) -> SyncDroplessArena {
462- SyncDroplessArena {
463- lock : MTLock :: new ( DroplessArena :: new ( ) )
464- }
465- }
466-
467459 #[ inline( always) ]
468460 pub fn in_arena < T : ?Sized > ( & self , ptr : * const T ) -> bool {
469461 self . lock . lock ( ) . in_arena ( ptr)
0 commit comments