File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -582,11 +582,8 @@ extern {
582582/// the same contents can exist in the same context.
583583/// This means we can use pointer + length for both
584584/// equality comparisons and hashing.
585- /// Empty slices are encoded in the pointer to this as `1`
586585pub struct Slice < T > ( PhantomData < T > , OpaqueSliceContents ) ;
587- /*
588- const EMPTY_SLICE: usize = 1;
589- */
586+
590587impl < T > Slice < T > {
591588 /// Returns the offset of the array
592589 #[ inline( always) ]
@@ -663,9 +660,6 @@ impl<T> Deref for Slice<T> {
663660 #[ inline( always) ]
664661 fn deref ( & self ) -> & [ T ] {
665662 unsafe {
666- /*if self as *const _ as usize == EMPTY_SLICE {
667- return &[];
668- }*/
669663 let raw = self as * const _ as * const u8 ;
670664 let len = * ( raw as * const usize ) ;
671665 let slice = raw. offset ( Slice :: < T > :: offset ( ) as isize ) ;
@@ -688,7 +682,10 @@ impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice<Ty<'tcx>> {}
688682impl < T > Slice < T > {
689683 #[ inline( always) ]
690684 pub fn empty < ' a > ( ) -> & ' a Slice < T > {
691- static EMPTY_SLICE : [ usize ; 32 ] = [ 0 ; 32 ] ;
685+ #[ repr( align( 64 ) , C ) ]
686+ struct EmptySlice ( [ usize ; 64 ] ) ;
687+ static EMPTY_SLICE : EmptySlice = EmptySlice ( [ 0 ; 64 ] ) ;
688+ assert ! ( mem:: align_of:: <T >( ) <= 64 ) ;
692689 unsafe {
693690 & * ( & EMPTY_SLICE as * const _ as * const Slice < T > )
694691 }
You can’t perform that action at this time.
0 commit comments