Skip to content

Commit 7bde8ee

Browse files
committed
wip
1 parent 878356f commit 7bde8ee

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/librustc/ty/mod.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ extern {
584584
/// equality comparisons and hashing.
585585
/// Empty slices are encoded in the pointer to this as `1`
586586
pub struct Slice<T>(PhantomData<T>, OpaqueSliceContents);
587-
587+
/*
588588
const EMPTY_SLICE: usize = 1;
589-
589+
*/
590590
impl<T> Slice<T> {
591591
/// Returns the offset of the array
592592
#[inline(always)]
@@ -641,13 +641,15 @@ impl<T: Encodable> Encodable for Slice<T> {
641641
}
642642
}
643643

644-
impl<T> PartialEq for Slice<T> {
644+
impl<T: PartialEq> PartialEq for Slice<T> {
645645
#[inline]
646646
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
648650
}
649651
}
650-
impl<T> Eq for Slice<T> {}
652+
impl<T: Eq> Eq for Slice<T> {}
651653

652654
impl<T> Hash for Slice<T> {
653655
#[inline]
@@ -661,9 +663,9 @@ impl<T> Deref for Slice<T> {
661663
#[inline(always)]
662664
fn deref(&self) -> &[T] {
663665
unsafe {
664-
if self as *const _ as usize == EMPTY_SLICE {
666+
/*if self as *const _ as usize == EMPTY_SLICE {
665667
return &[];
666-
}
668+
}*/
667669
let raw = self as *const _ as *const u8;
668670
let len = *(raw as *const usize);
669671
let slice = raw.offset(Slice::<T>::offset() as isize);
@@ -686,8 +688,9 @@ impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice<Ty<'tcx>> {}
686688
impl<T> Slice<T> {
687689
#[inline(always)]
688690
pub fn empty<'a>() -> &'a Slice<T> {
691+
static EMPTY_SLICE: [usize; 32] = [0; 32];
689692
unsafe {
690-
&*(EMPTY_SLICE as *const _)
693+
&*(&EMPTY_SLICE as *const _ as *const Slice<T>)
691694
}
692695
}
693696
}

0 commit comments

Comments
 (0)