@@ -90,11 +90,8 @@ pub use crate::intrinsics::copy;
9090#[ doc( inline) ]
9191pub use crate :: intrinsics:: write_bytes;
9292
93- #[ cfg( not( bootstrap) ) ]
9493mod metadata;
95- #[ cfg( not( bootstrap) ) ]
9694pub ( crate ) use metadata:: PtrRepr ;
97- #[ cfg( not( bootstrap) ) ]
9895#[ unstable( feature = "ptr_metadata" , issue = "81513" ) ]
9996pub use metadata:: { from_raw_parts, from_raw_parts_mut, metadata, DynMetadata , Pointee , Thin } ;
10097
@@ -236,33 +233,6 @@ pub const fn null_mut<T>() -> *mut T {
236233 0 as * mut T
237234}
238235
239- #[ cfg( bootstrap) ]
240- #[ repr( C ) ]
241- pub ( crate ) union Repr < T > {
242- pub ( crate ) rust : * const [ T ] ,
243- rust_mut : * mut [ T ] ,
244- pub ( crate ) raw : FatPtr < T > ,
245- }
246-
247- #[ cfg( bootstrap) ]
248- #[ repr( C ) ]
249- pub ( crate ) struct FatPtr < T > {
250- data : * const T ,
251- pub ( crate ) len : usize ,
252- }
253-
254- #[ cfg( bootstrap) ]
255- // Manual impl needed to avoid `T: Clone` bound.
256- impl < T > Clone for FatPtr < T > {
257- fn clone ( & self ) -> Self {
258- * self
259- }
260- }
261-
262- #[ cfg( bootstrap) ]
263- // Manual impl needed to avoid `T: Copy` bound.
264- impl < T > Copy for FatPtr < T > { }
265-
266236/// Forms a raw slice from a pointer and a length.
267237///
268238/// The `len` argument is the number of **elements**, not the number of bytes.
@@ -287,14 +257,6 @@ impl<T> Copy for FatPtr<T> {}
287257#[ stable( feature = "slice_from_raw_parts" , since = "1.42.0" ) ]
288258#[ rustc_const_unstable( feature = "const_slice_from_raw_parts" , issue = "67456" ) ]
289259pub const fn slice_from_raw_parts < T > ( data : * const T , len : usize ) -> * const [ T ] {
290- #[ cfg( bootstrap) ]
291- {
292- // SAFETY: Accessing the value from the `Repr` union is safe since *const [T]
293- // and FatPtr have the same memory layouts. Only std can make this
294- // guarantee.
295- unsafe { Repr { raw : FatPtr { data, len } } . rust }
296- }
297- #[ cfg( not( bootstrap) ) ]
298260 from_raw_parts ( data. cast ( ) , len)
299261}
300262
@@ -327,13 +289,6 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
327289#[ stable( feature = "slice_from_raw_parts" , since = "1.42.0" ) ]
328290#[ rustc_const_unstable( feature = "const_slice_from_raw_parts" , issue = "67456" ) ]
329291pub const fn slice_from_raw_parts_mut < T > ( data : * mut T , len : usize ) -> * mut [ T ] {
330- #[ cfg( bootstrap) ]
331- {
332- // SAFETY: Accessing the value from the `Repr` union is safe since *mut [T]
333- // and FatPtr have the same memory layouts
334- unsafe { Repr { raw : FatPtr { data, len } } . rust_mut }
335- }
336- #[ cfg( not( bootstrap) ) ]
337292 from_raw_parts_mut ( data. cast ( ) , len)
338293}
339294
0 commit comments