@@ -584,9 +584,9 @@ extern {
584
584
/// equality comparisons and hashing.
585
585
/// Empty slices are encoded in the pointer to this as `1`
586
586
pub struct Slice < T > ( PhantomData < T > , OpaqueSliceContents ) ;
587
-
587
+ /*
588
588
const EMPTY_SLICE: usize = 1;
589
-
589
+ */
590
590
impl < T > Slice < T > {
591
591
/// Returns the offset of the array
592
592
#[ inline( always) ]
@@ -641,13 +641,15 @@ impl<T: Encodable> Encodable for Slice<T> {
641
641
}
642
642
}
643
643
644
- impl < T > PartialEq for Slice < T > {
644
+ impl < T : PartialEq > PartialEq for Slice < T > {
645
645
#[ inline]
646
646
fn eq ( & self , other : & Slice < T > ) -> bool {
647
- ( self as * const _ ) == ( other as * const _ )
647
+ let r = ( self as * const _ ) == ( other as * const _ ) ;
648
+ assert_eq ! ( r, * * self == * * other) ;
649
+ r
648
650
}
649
651
}
650
- impl < T > Eq for Slice < T > { }
652
+ impl < T : Eq > Eq for Slice < T > { }
651
653
652
654
impl < T > Hash for Slice < T > {
653
655
#[ inline]
@@ -661,9 +663,9 @@ impl<T> Deref for Slice<T> {
661
663
#[ inline( always) ]
662
664
fn deref ( & self ) -> & [ T ] {
663
665
unsafe {
664
- if self as * const _ as usize == EMPTY_SLICE {
666
+ /* if self as *const _ as usize == EMPTY_SLICE {
665
667
return &[];
666
- }
668
+ }*/
667
669
let raw = self as * const _ as * const u8 ;
668
670
let len = * ( raw as * const usize ) ;
669
671
let slice = raw. offset ( Slice :: < T > :: offset ( ) as isize ) ;
@@ -686,8 +688,9 @@ impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice<Ty<'tcx>> {}
686
688
impl < T > Slice < T > {
687
689
#[ inline( always) ]
688
690
pub fn empty < ' a > ( ) -> & ' a Slice < T > {
691
+ static EMPTY_SLICE : [ usize ; 32 ] = [ 0 ; 32 ] ;
689
692
unsafe {
690
- & * ( EMPTY_SLICE as * const _ )
693
+ & * ( & EMPTY_SLICE as * const _ as * const Slice < T > )
691
694
}
692
695
}
693
696
}
0 commit comments