@@ -35,13 +35,6 @@ pub type List<T> = RawList<(), T>;
3535/// [`Hash`] and [`Encodable`].
3636#[ repr( C ) ]
3737pub struct RawList < H , T > {
38- skel : ListSkeleton < H , T > ,
39- }
40-
41- /// A [`RawList`] without the unsized tail. This type is used for layout computation
42- /// and constructing empty lists.
43- #[ repr( C ) ]
44- struct ListSkeleton < H , T > {
4538 header : H ,
4639 len : usize ,
4740 /// Although this claims to be a zero-length array, in practice `len`
@@ -58,7 +51,7 @@ impl<T> Default for &List<T> {
5851impl < H , T > RawList < H , T > {
5952 #[ inline( always) ]
6053 pub fn len ( & self ) -> usize {
61- self . skel . len
54+ self . len
6255 }
6356
6457 #[ inline( always) ]
@@ -89,18 +82,18 @@ impl<H, T> RawList<H, T> {
8982 assert ! ( !slice. is_empty( ) ) ;
9083
9184 let ( layout, _offset) =
92- Layout :: new :: < ListSkeleton < H , T > > ( ) . extend ( Layout :: for_value :: < [ T ] > ( slice) ) . unwrap ( ) ;
85+ Layout :: new :: < RawList < H , T > > ( ) . extend ( Layout :: for_value :: < [ T ] > ( slice) ) . unwrap ( ) ;
9386
9487 let mem = arena. dropless . alloc_raw ( layout) as * mut RawList < H , T > ;
9588 unsafe {
9689 // Write the header
97- ( & raw mut ( * mem) . skel . header ) . write ( header) ;
90+ ( & raw mut ( * mem) . header ) . write ( header) ;
9891
9992 // Write the length
100- ( & raw mut ( * mem) . skel . len ) . write ( slice. len ( ) ) ;
93+ ( & raw mut ( * mem) . len ) . write ( slice. len ( ) ) ;
10194
10295 // Write the elements
103- ( & raw mut ( * mem) . skel . data )
96+ ( & raw mut ( * mem) . data )
10497 . cast :: < T > ( )
10598 . copy_from_nonoverlapping ( slice. as_ptr ( ) , slice. len ( ) ) ;
10699
@@ -144,8 +137,8 @@ macro_rules! impl_list_empty {
144137 #[ repr( align( 64 ) ) ]
145138 struct MaxAlign ;
146139
147- static EMPTY : ListSkeleton <$header_ty, MaxAlign > =
148- ListSkeleton { header: $header_init, len: 0 , data: [ ] } ;
140+ static EMPTY : RawList <$header_ty, MaxAlign > =
141+ RawList { header: $header_init, len: 0 , data: [ ] } ;
149142
150143 assert!( align_of:: <T >( ) <= align_of:: <MaxAlign >( ) ) ;
151144
@@ -229,12 +222,12 @@ impl<H, T> Deref for RawList<H, T> {
229222impl < H , T > AsRef < [ T ] > for RawList < H , T > {
230223 #[ inline( always) ]
231224 fn as_ref ( & self ) -> & [ T ] {
232- let data_ptr = ( & raw const self . skel . data ) . cast :: < T > ( ) ;
225+ let data_ptr = ( & raw const self . data ) . cast :: < T > ( ) ;
233226 // SAFETY: `data_ptr` has the same provenance as `self` and can therefore
234227 // access the `self.skel.len` elements stored at `self.skel.data`.
235228 // Note that we specifically don't reborrow `&self.skel.data`, because that
236229 // would give us a pointer with provenance over 0 bytes.
237- unsafe { slice:: from_raw_parts ( data_ptr, self . skel . len ) }
230+ unsafe { slice:: from_raw_parts ( data_ptr, self . len ) }
238231 }
239232}
240233
@@ -256,12 +249,12 @@ pub type ListWithCachedTypeInfo<T> = RawList<TypeInfo, T>;
256249impl < T > ListWithCachedTypeInfo < T > {
257250 #[ inline( always) ]
258251 pub fn flags ( & self ) -> TypeFlags {
259- self . skel . header . flags
252+ self . header . flags
260253 }
261254
262255 #[ inline( always) ]
263256 pub fn outer_exclusive_binder ( & self ) -> DebruijnIndex {
264- self . skel . header . outer_exclusive_binder
257+ self . header . outer_exclusive_binder
265258 }
266259}
267260
0 commit comments