about summary refs log tree commit diff
path: root/src/libcore/slice
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-06-19 16:37:58 +0000
committerbors <bors@rust-lang.org>2019-06-19 16:37:58 +0000
commit5e0c6a69e075d9c7d19e28264bb8941f72ecaf4e (patch)
tree340f2e3775fb368108e2fe31ba8b24c9aa521111 /src/libcore/slice
parente79b2a18a21e6b178d73473bb8fdbf3d18c66051 (diff)
parentbf6c505c23a1026282cc0518743c9cd6e727c2aa (diff)
downloadrust-5e0c6a69e075d9c7d19e28264bb8941f72ecaf4e.tar.gz
rust-5e0c6a69e075d9c7d19e28264bb8941f72ecaf4e.zip
Auto merge of #61962 - Centril:rollup-y6sg1zw, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #60667 ( Add functions for building raw slices to libcore )
 - #61547 (Support `cfg` and `cfg_attr` on generic parameters)
 - #61861 (Update rustfmt and rls)
 - #61940 (Make Place::ty iterate)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libcore/slice')
-rw-r--r--src/libcore/slice/mod.rs19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index b2376cdf9fa..af1b20a4c10 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -45,19 +45,6 @@ pub mod memchr;
 mod rotate;
 mod sort;
 
-#[repr(C)]
-union Repr<'a, T: 'a> {
-    rust: &'a [T],
-    rust_mut: &'a mut [T],
-    raw: FatPtr<T>,
-}
-
-#[repr(C)]
-struct FatPtr<T> {
-    data: *const T,
-    len: usize,
-}
-
 //
 // Extension traits
 //
@@ -78,7 +65,7 @@ impl<T> [T] {
     #[rustc_const_unstable(feature = "const_slice_len")]
     pub const fn len(&self) -> usize {
         unsafe {
-            Repr { rust: self }.raw.len
+            crate::ptr::Repr { rust: self }.raw.len
         }
     }
 
@@ -5195,7 +5182,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
     debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
     debug_assert!(mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize,
                   "attempt to create slice covering half the address space");
-    Repr { raw: FatPtr { data, len } }.rust
+    &*ptr::slice_from_raw_parts(data, len)
 }
 
 /// Performs the same functionality as [`from_raw_parts`], except that a
@@ -5216,7 +5203,7 @@ pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T]
     debug_assert!(data as usize % mem::align_of::<T>() == 0, "attempt to create unaligned slice");
     debug_assert!(mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize,
                   "attempt to create slice covering half the address space");
-    Repr { raw: FatPtr { data, len } }.rust_mut
+    &mut *ptr::slice_from_raw_parts_mut(data, len)
 }
 
 /// Converts a reference to T into a slice of length 1 (without copying).