File tree 1 file changed +5
-8
lines changed
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -582,11 +582,8 @@ extern {
582
582
/// the same contents can exist in the same context.
583
583
/// This means we can use pointer + length for both
584
584
/// equality comparisons and hashing.
585
- /// Empty slices are encoded in the pointer to this as `1`
586
585
pub struct Slice < T > ( PhantomData < T > , OpaqueSliceContents ) ;
587
- /*
588
- const EMPTY_SLICE: usize = 1;
589
- */
586
+
590
587
impl < T > Slice < T > {
591
588
/// Returns the offset of the array
592
589
#[ inline( always) ]
@@ -663,9 +660,6 @@ impl<T> Deref for Slice<T> {
663
660
#[ inline( always) ]
664
661
fn deref ( & self ) -> & [ T ] {
665
662
unsafe {
666
- /*if self as *const _ as usize == EMPTY_SLICE {
667
- return &[];
668
- }*/
669
663
let raw = self as * const _ as * const u8 ;
670
664
let len = * ( raw as * const usize ) ;
671
665
let slice = raw. offset ( Slice :: < T > :: offset ( ) as isize ) ;
@@ -688,7 +682,10 @@ impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice<Ty<'tcx>> {}
688
682
impl < T > Slice < T > {
689
683
#[ inline( always) ]
690
684
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 ) ;
692
689
unsafe {
693
690
& * ( & EMPTY_SLICE as * const _ as * const Slice < T > )
694
691
}
You can’t perform that action at this time.
0 commit comments