diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index afda70f4fcc0a..fb15533f33c54 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -285,12 +285,12 @@ impl SliceExt for [T] { #[inline] unsafe fn get_unchecked(&self, index: usize) -> &T { - &*(self.repr().data.offset(index as isize)) + &*(self.as_ptr().offset(index as isize)) } #[inline] fn as_ptr(&self) -> *const T { - self.repr().data + self as *const [T] as *const T } fn binary_search_by(&self, mut f: F) -> Result where @@ -448,12 +448,12 @@ impl SliceExt for [T] { #[inline] unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T { - &mut *(self.repr().data as *mut T).offset(index as isize) + &mut *self.as_mut_ptr().offset(index as isize) } #[inline] fn as_mut_ptr(&mut self) -> *mut T { - self.repr().data as *mut T + self as *mut [T] as *mut T } #[inline] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 4d367cfd432f9..a555b8592912e 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1894,7 +1894,7 @@ impl StrExt for str { #[inline] fn as_ptr(&self) -> *const u8 { - self.repr().data + self as *const str as *const u8 } #[inline]