Skip to content

Commit 60ca7ef

Browse files
committed
wip
1 parent 7bde8ee commit 60ca7ef

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/librustc/ty/mod.rs

+5-8
Original file line numberDiff line numberDiff 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`
586585
pub struct Slice<T>(PhantomData<T>, OpaqueSliceContents);
587-
/*
588-
const EMPTY_SLICE: usize = 1;
589-
*/
586+
590587
impl<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>> {}
688682
impl<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
}

0 commit comments

Comments
 (0)