about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
Diffstat (limited to 'library')
-rw-r--r--library/alloc/src/lib.rs4
-rw-r--r--library/core/src/hash/mod.rs52
-rw-r--r--library/core/src/lib.rs6
-rw-r--r--library/core/src/macros/mod.rs2
-rw-r--r--library/core/src/ops/deref.rs2
-rw-r--r--library/core/src/prelude/v1.rs2
-rw-r--r--library/core/src/ptr/const_ptr.rs8
-rw-r--r--library/core/src/ptr/mod.rs45
-rw-r--r--library/core/src/ptr/mut_ptr.rs8
-rw-r--r--library/core/src/ptr/non_null.rs2
-rw-r--r--library/core/src/slice/mod.rs28
-rw-r--r--library/core/tests/lib.rs5
-rw-r--r--library/core/tests/ptr.rs7
-rw-r--r--library/std/src/lib.rs3
-rw-r--r--library/std/src/prelude/v1.rs2
15 files changed, 22 insertions, 154 deletions
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index fb243100990..14cb1d3b405 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -133,7 +133,6 @@
 #![feature(trusted_len)]
 #![feature(unboxed_closures)]
 #![feature(unicode_internals)]
-#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
 #![feature(unsize)]
 #![feature(unsized_fn_params)]
 #![feature(allocator_internals)]
@@ -142,8 +141,7 @@
 #![feature(alloc_layout_extra)]
 #![feature(trusted_random_access)]
 #![feature(try_trait)]
-#![cfg_attr(bootstrap, feature(type_alias_impl_trait))]
-#![cfg_attr(not(bootstrap), feature(min_type_alias_impl_trait))]
+#![feature(min_type_alias_impl_trait)]
 #![feature(associated_type_bounds)]
 #![feature(slice_group_by)]
 #![feature(decl_macro)]
diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs
index 7bfa58d34ed..0c3303cc210 100644
--- a/library/core/src/hash/mod.rs
+++ b/library/core/src/hash/mod.rs
@@ -691,29 +691,9 @@ mod impls {
     impl<T: ?Sized> Hash for *const T {
         #[inline]
         fn hash<H: Hasher>(&self, state: &mut H) {
-            #[cfg(not(bootstrap))]
-            {
-                let (address, metadata) = self.to_raw_parts();
-                state.write_usize(address as usize);
-                metadata.hash(state);
-            }
-            #[cfg(bootstrap)]
-            {
-                if mem::size_of::<Self>() == mem::size_of::<usize>() {
-                    // Thin pointer
-                    state.write_usize(*self as *const () as usize);
-                } else {
-                    // Fat pointer
-                    // SAFETY: we are accessing the memory occupied by `self`
-                    // which is guaranteed to be valid.
-                    // This assumes a fat pointer can be represented by a `(usize, usize)`,
-                    // which is safe to do in `std` because it is shipped and kept in sync
-                    // with the implementation of fat pointers in `rustc`.
-                    let (a, b) = unsafe { *(self as *const Self as *const (usize, usize)) };
-                    state.write_usize(a);
-                    state.write_usize(b);
-                }
-            }
+            let (address, metadata) = self.to_raw_parts();
+            state.write_usize(address as usize);
+            metadata.hash(state);
         }
     }
 
@@ -721,29 +701,9 @@ mod impls {
     impl<T: ?Sized> Hash for *mut T {
         #[inline]
         fn hash<H: Hasher>(&self, state: &mut H) {
-            #[cfg(not(bootstrap))]
-            {
-                let (address, metadata) = self.to_raw_parts();
-                state.write_usize(address as usize);
-                metadata.hash(state);
-            }
-            #[cfg(bootstrap)]
-            {
-                if mem::size_of::<Self>() == mem::size_of::<usize>() {
-                    // Thin pointer
-                    state.write_usize(*self as *const () as usize);
-                } else {
-                    // Fat pointer
-                    // SAFETY: we are accessing the memory occupied by `self`
-                    // which is guaranteed to be valid.
-                    // This assumes a fat pointer can be represented by a `(usize, usize)`,
-                    // which is safe to do in `std` because it is shipped and kept in sync
-                    // with the implementation of fat pointers in `rustc`.
-                    let (a, b) = unsafe { *(self as *const Self as *const (usize, usize)) };
-                    state.write_usize(a);
-                    state.write_usize(b);
-                }
-            }
+            let (address, metadata) = self.to_raw_parts();
+            state.write_usize(address as usize);
+            metadata.hash(state);
         }
     }
 }
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 158b1e152ad..013e98a8660 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -129,7 +129,7 @@
 #![feature(auto_traits)]
 #![cfg_attr(bootstrap, feature(or_patterns))]
 #![feature(prelude_import)]
-#![cfg_attr(not(bootstrap), feature(ptr_metadata))]
+#![feature(ptr_metadata)]
 #![feature(repr_simd, platform_intrinsics)]
 #![feature(rustc_attrs)]
 #![feature(simd_ffi)]
@@ -167,7 +167,6 @@
 #![feature(slice_ptr_get)]
 #![feature(no_niche)] // rust-lang/rust#68303
 #![feature(int_error_matching)]
-#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
 #![deny(unsafe_op_in_unsafe_fn)]
 
 #[prelude_import]
@@ -299,8 +298,7 @@ pub mod primitive;
     unused_imports,
     unsafe_op_in_unsafe_fn
 )]
-#[cfg_attr(bootstrap, allow(non_autolinks))]
-#[cfg_attr(not(bootstrap), allow(rustdoc::non_autolinks))]
+#[allow(rustdoc::non_autolinks)]
 // FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
 // merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
 #[allow(clashing_extern_declarations)]
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 99894b5605e..5d9b0f80d3a 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -1391,7 +1391,6 @@ pub(crate) mod builtin {
     }
 
     /// Attribute macro used to apply derive macros.
-    #[cfg(not(bootstrap))]
     #[stable(feature = "rust1", since = "1.0.0")]
     #[rustc_builtin_macro]
     pub macro derive($item:item) {
@@ -1453,7 +1452,6 @@ pub(crate) mod builtin {
     }
 
     /// Expands all `#[cfg]` and `#[cfg_attr]` attributes in the code fragment it's applied to.
-    #[cfg(not(bootstrap))]
     #[unstable(
         feature = "cfg_eval",
         issue = "82679",
diff --git a/library/core/src/ops/deref.rs b/library/core/src/ops/deref.rs
index 10e3ce67448..dcf3ce070ec 100644
--- a/library/core/src/ops/deref.rs
+++ b/library/core/src/ops/deref.rs
@@ -65,7 +65,7 @@ pub trait Deref {
     /// The resulting type after dereferencing.
     #[stable(feature = "rust1", since = "1.0.0")]
     #[rustc_diagnostic_item = "deref_target"]
-    #[cfg_attr(not(bootstrap), lang = "deref_target")]
+    #[lang = "deref_target"]
     type Target: ?Sized;
 
     /// Dereferences the value.
diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs
index 7d33ca8bb69..c89fe57cb05 100644
--- a/library/core/src/prelude/v1.rs
+++ b/library/core/src/prelude/v1.rs
@@ -67,7 +67,6 @@ pub use crate::macros::builtin::{
     bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable,
 };
 
-#[cfg(not(bootstrap))]
 #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
 #[doc(no_inline)]
 pub use crate::macros::builtin::derive;
@@ -80,7 +79,6 @@ pub use crate::macros::builtin::derive;
 #[doc(no_inline)]
 pub use crate::macros::builtin::cfg_accessible;
 
-#[cfg(not(bootstrap))]
 #[unstable(
     feature = "cfg_eval",
     issue = "82679",
diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs
index 25b8f435acc..f18387d020d 100644
--- a/library/core/src/ptr/const_ptr.rs
+++ b/library/core/src/ptr/const_ptr.rs
@@ -51,7 +51,6 @@ impl<T: ?Sized> *const T {
     /// Decompose a (possibly wide) pointer into is address and metadata components.
     ///
     /// The pointer can be later reconstructed with [`from_raw_parts`].
-    #[cfg(not(bootstrap))]
     #[unstable(feature = "ptr_metadata", issue = "81513")]
     #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
     #[inline]
@@ -915,13 +914,6 @@ impl<T> *const [T] {
     #[unstable(feature = "slice_ptr_len", issue = "71146")]
     #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
     pub const fn len(self) -> usize {
-        #[cfg(bootstrap)]
-        {
-            // SAFETY: this is safe because `*const [T]` and `FatPtr<T>` have the same layout.
-            // Only `std` can make this guarantee.
-            unsafe { Repr { rust: self }.raw }.len
-        }
-        #[cfg(not(bootstrap))]
         metadata(self)
     }
 
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
index 6412bd41a8c..52660116026 100644
--- a/library/core/src/ptr/mod.rs
+++ b/library/core/src/ptr/mod.rs
@@ -90,11 +90,8 @@ pub use crate::intrinsics::copy;
 #[doc(inline)]
 pub use crate::intrinsics::write_bytes;
 
-#[cfg(not(bootstrap))]
 mod metadata;
-#[cfg(not(bootstrap))]
 pub(crate) use metadata::PtrRepr;
-#[cfg(not(bootstrap))]
 #[unstable(feature = "ptr_metadata", issue = "81513")]
 pub use metadata::{from_raw_parts, from_raw_parts_mut, metadata, DynMetadata, Pointee, Thin};
 
@@ -236,33 +233,6 @@ pub const fn null_mut<T>() -> *mut T {
     0 as *mut T
 }
 
-#[cfg(bootstrap)]
-#[repr(C)]
-pub(crate) union Repr<T> {
-    pub(crate) rust: *const [T],
-    rust_mut: *mut [T],
-    pub(crate) raw: FatPtr<T>,
-}
-
-#[cfg(bootstrap)]
-#[repr(C)]
-pub(crate) struct FatPtr<T> {
-    data: *const T,
-    pub(crate) len: usize,
-}
-
-#[cfg(bootstrap)]
-// Manual impl needed to avoid `T: Clone` bound.
-impl<T> Clone for FatPtr<T> {
-    fn clone(&self) -> Self {
-        *self
-    }
-}
-
-#[cfg(bootstrap)]
-// Manual impl needed to avoid `T: Copy` bound.
-impl<T> Copy for FatPtr<T> {}
-
 /// Forms a raw slice from a pointer and a length.
 ///
 /// The `len` argument is the number of **elements**, not the number of bytes.
@@ -287,14 +257,6 @@ impl<T> Copy for FatPtr<T> {}
 #[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
 #[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
 pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
-    #[cfg(bootstrap)]
-    {
-        // SAFETY: Accessing the value from the `Repr` union is safe since *const [T]
-        // and FatPtr have the same memory layouts. Only std can make this
-        // guarantee.
-        unsafe { Repr { raw: FatPtr { data, len } }.rust }
-    }
-    #[cfg(not(bootstrap))]
     from_raw_parts(data.cast(), len)
 }
 
@@ -327,13 +289,6 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
 #[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
 #[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
 pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
-    #[cfg(bootstrap)]
-    {
-        // SAFETY: Accessing the value from the `Repr` union is safe since *mut [T]
-        // and FatPtr have the same memory layouts
-        unsafe { Repr { raw: FatPtr { data, len } }.rust_mut }
-    }
-    #[cfg(not(bootstrap))]
     from_raw_parts_mut(data.cast(), len)
 }
 
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index 732e1273b4b..3c6f1978283 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -50,7 +50,6 @@ impl<T: ?Sized> *mut T {
     /// Decompose a (possibly wide) pointer into is address and metadata components.
     ///
     /// The pointer can be later reconstructed with [`from_raw_parts_mut`].
-    #[cfg(not(bootstrap))]
     #[unstable(feature = "ptr_metadata", issue = "81513")]
     #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
     #[inline]
@@ -1175,13 +1174,6 @@ impl<T> *mut [T] {
     #[unstable(feature = "slice_ptr_len", issue = "71146")]
     #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
     pub const fn len(self) -> usize {
-        #[cfg(bootstrap)]
-        {
-            // SAFETY: this is safe because `*const [T]` and `FatPtr<T>` have the same layout.
-            // Only `std` can make this guarantee.
-            unsafe { Repr { rust_mut: self }.raw }.len
-        }
-        #[cfg(not(bootstrap))]
         metadata(self)
     }
 
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs
index 83b88ffd916..e525f616043 100644
--- a/library/core/src/ptr/non_null.rs
+++ b/library/core/src/ptr/non_null.rs
@@ -181,7 +181,6 @@ impl<T: ?Sized> NonNull<T> {
     /// See the documentation of [`std::ptr::from_raw_parts`] for more details.
     ///
     /// [`std::ptr::from_raw_parts`]: crate::ptr::from_raw_parts
-    #[cfg(not(bootstrap))]
     #[unstable(feature = "ptr_metadata", issue = "81513")]
     #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
     #[inline]
@@ -198,7 +197,6 @@ impl<T: ?Sized> NonNull<T> {
     /// Decompose a (possibly wide) pointer into is address and metadata components.
     ///
     /// The pointer can be later reconstructed with [`NonNull::from_raw_parts`].
-    #[cfg(not(bootstrap))]
     #[unstable(feature = "ptr_metadata", issue = "81513")]
     #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
     #[inline]
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs
index e4b1bffcfe0..ec28cdd1ba0 100644
--- a/library/core/src/slice/mod.rs
+++ b/library/core/src/slice/mod.rs
@@ -102,23 +102,14 @@ impl<T> [T] {
     // SAFETY: const sound because we transmute out the length field as a usize (which it must be)
     #[rustc_allow_const_fn_unstable(const_fn_union)]
     pub const fn len(&self) -> usize {
-        #[cfg(bootstrap)]
-        {
-            // SAFETY: this is safe because `&[T]` and `FatPtr<T>` have the same layout.
-            // Only `std` can make this guarantee.
-            unsafe { crate::ptr::Repr { rust: self }.raw.len }
-        }
-        #[cfg(not(bootstrap))]
-        {
-            // FIXME: Replace with `crate::ptr::metadata(self)` when that is const-stable.
-            // As of this writing this causes a "Const-stable functions can only call other
-            // const-stable functions" error.
-
-            // SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
-            // and PtrComponents<T> have the same memory layouts. Only std can make this
-            // guarantee.
-            unsafe { crate::ptr::PtrRepr { const_ptr: self }.components.metadata }
-        }
+        // FIXME: Replace with `crate::ptr::metadata(self)` when that is const-stable.
+        // As of this writing this causes a "Const-stable functions can only call other
+        // const-stable functions" error.
+
+        // SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
+        // and PtrComponents<T> have the same memory layouts. Only std can make this
+        // guarantee.
+        unsafe { crate::ptr::PtrRepr { const_ptr: self }.components.metadata }
     }
 
     /// Returns `true` if the slice has a length of 0.
@@ -2265,8 +2256,7 @@ impl<T> [T] {
     // in crate `alloc`, and as such doesn't exists yet when building `core`.
     // links to downstream crate: #74481. Since primitives are only documented in
     // libstd (#73423), this never leads to broken links in practice.
-    #[cfg_attr(not(bootstrap), allow(rustdoc::broken_intra_doc_links))]
-    #[cfg_attr(bootstrap, allow(broken_intra_doc_links))]
+    #[allow(rustdoc::broken_intra_doc_links)]
     #[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
     #[inline]
     pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, mut f: F) -> Result<usize, usize>
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 997e618cc51..1d885eb1092 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -68,7 +68,7 @@
 #![feature(option_result_unwrap_unchecked)]
 #![feature(result_into_ok_or_err)]
 #![feature(peekable_peek_mut)]
-#![cfg_attr(not(bootstrap), feature(ptr_metadata))]
+#![feature(ptr_metadata)]
 #![feature(once_cell)]
 #![feature(unsized_tuple_coercion)]
 #![feature(nonzero_leading_trailing_zeros)]
@@ -76,8 +76,7 @@
 #![feature(integer_atomics)]
 #![feature(slice_group_by)]
 #![feature(trusted_random_access)]
-#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
-#![cfg_attr(not(bootstrap), feature(unsize))]
+#![feature(unsize)]
 #![deny(unsafe_op_in_unsafe_fn)]
 
 extern crate test;
diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs
index 224a58e3ccd..11af8090c3a 100644
--- a/library/core/tests/ptr.rs
+++ b/library/core/tests/ptr.rs
@@ -1,8 +1,6 @@
 use core::cell::RefCell;
-#[cfg(not(bootstrap))]
 use core::ptr;
 use core::ptr::*;
-#[cfg(not(bootstrap))]
 use std::fmt::{Debug, Display};
 
 #[test]
@@ -419,7 +417,6 @@ fn offset_from() {
 }
 
 #[test]
-#[cfg(not(bootstrap))]
 fn ptr_metadata() {
     struct Unit;
     struct Pair<A, B: ?Sized>(A, B);
@@ -478,7 +475,6 @@ fn ptr_metadata() {
 }
 
 #[test]
-#[cfg(not(bootstrap))]
 fn ptr_metadata_bounds() {
     fn metadata_eq_method_address<T: ?Sized>() -> usize {
         // The `Metadata` associated type has an `Ord` bound, so this is valid:
@@ -510,7 +506,6 @@ fn ptr_metadata_bounds() {
 }
 
 #[test]
-#[cfg(not(bootstrap))]
 fn dyn_metadata() {
     #[derive(Debug)]
     #[repr(align(32))]
@@ -530,7 +525,6 @@ fn dyn_metadata() {
 }
 
 #[test]
-#[cfg(not(bootstrap))]
 fn from_raw_parts() {
     let mut value = 5_u32;
     let address = &mut value as *mut _ as *mut ();
@@ -557,7 +551,6 @@ fn from_raw_parts() {
 }
 
 #[test]
-#[cfg(not(bootstrap))]
 fn thin_box() {
     let foo = ThinBox::<dyn Display>::new(4);
     assert_eq!(foo.to_string(), "4");
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 6ab68100b1d..c983022746c 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -234,7 +234,7 @@
 #![feature(box_syntax)]
 #![feature(c_variadic)]
 #![feature(cfg_accessible)]
-#![cfg_attr(not(bootstrap), feature(cfg_eval))]
+#![feature(cfg_eval)]
 #![feature(cfg_target_has_atomic)]
 #![feature(cfg_target_thread_local)]
 #![feature(char_error_internals)]
@@ -331,7 +331,6 @@
 #![feature(try_blocks)]
 #![feature(try_reserve)]
 #![feature(unboxed_closures)]
-#![cfg_attr(bootstrap, feature(unsafe_block_in_unsafe_fn))]
 #![feature(unsafe_cell_raw_get)]
 #![feature(unwind_attributes)]
 #![feature(vec_into_raw_parts)]
diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs
index c5b871edbf2..4a3c3ba1635 100644
--- a/library/std/src/prelude/v1.rs
+++ b/library/std/src/prelude/v1.rs
@@ -54,7 +54,6 @@ pub use core::prelude::v1::{
     bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable,
 };
 
-#[cfg(not(bootstrap))]
 #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
 #[doc(hidden)]
 pub use core::prelude::v1::derive;
@@ -67,7 +66,6 @@ pub use core::prelude::v1::derive;
 #[doc(hidden)]
 pub use core::prelude::v1::cfg_accessible;
 
-#[cfg(not(bootstrap))]
 #[unstable(
     feature = "cfg_eval",
     issue = "82679",