From d8fe5899dc83aa23c6b6ec6bb48ddebc21b95bb3 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 11 Jun 2024 15:08:34 +0200 Subject: [PATCH] remove cfg(bootstrap) --- alloc/src/boxed.rs | 3 +-- alloc/src/lib.rs | 1 - core/src/future/async_drop.rs | 1 - core/src/future/future.rs | 2 +- core/src/intrinsics.rs | 11 +++++---- core/src/intrinsics/simd.rs | 1 - core/src/iter/traits/collect.rs | 3 +-- core/src/num/int_macros.rs | 18 ++++++--------- core/src/ops/async_function.rs | 8 +++---- core/src/ptr/metadata.rs | 40 +-------------------------------- std/src/env.rs | 16 ------------- 11 files changed, 20 insertions(+), 84 deletions(-) diff --git a/alloc/src/boxed.rs b/alloc/src/boxed.rs index 2b5141585de49..01a954ed75beb 100644 --- a/alloc/src/boxed.rs +++ b/alloc/src/boxed.rs @@ -145,8 +145,7 @@ //! to `into_iter()` for boxed slices will defer to the slice implementation on editions before //! 2024: //! -#![cfg_attr(bootstrap, doc = "```rust,edition2021,ignore")] -#![cfg_attr(not(bootstrap), doc = "```rust,edition2021")] +//! ```rust,edition2021 //! // Rust 2015, 2018, and 2021: //! //! # #![allow(boxed_slice_into_iter)] // override our `deny(warnings)` diff --git a/alloc/src/lib.rs b/alloc/src/lib.rs index 4749b8880fbc4..895d1b8d59f2c 100644 --- a/alloc/src/lib.rs +++ b/alloc/src/lib.rs @@ -165,7 +165,6 @@ // // Language features: // tidy-alphabetical-start -#![cfg_attr(bootstrap, feature(exclusive_range_pattern))] #![cfg_attr(not(test), feature(coroutine_trait))] #![cfg_attr(test, feature(panic_update_hook))] #![cfg_attr(test, feature(test))] diff --git a/core/src/future/async_drop.rs b/core/src/future/async_drop.rs index 25138c445c437..5c3a0a98b105a 100644 --- a/core/src/future/async_drop.rs +++ b/core/src/future/async_drop.rs @@ -256,7 +256,6 @@ async unsafe fn either, M: IntoFuture, T } } -#[cfg(not(bootstrap))] #[lang = "async_drop_deferred_drop_in_place"] async unsafe fn deferred_drop_in_place(to_drop: *mut T) { // SAFETY: same safety requirements as with drop_in_place (implied by diff --git a/core/src/future/future.rs b/core/src/future/future.rs index 86963b548b9c6..c80cfdcebf70d 100644 --- a/core/src/future/future.rs +++ b/core/src/future/future.rs @@ -35,7 +35,7 @@ use crate::task::{Context, Poll}; pub trait Future { /// The type of value produced on completion. #[stable(feature = "futures_api", since = "1.36.0")] - #[cfg_attr(not(bootstrap), lang = "future_output")] + #[lang = "future_output"] type Output; /// Attempt to resolve the future to a final value, registering diff --git a/core/src/intrinsics.rs b/core/src/intrinsics.rs index 28397fe46190f..cd3534ecb1239 100644 --- a/core/src/intrinsics.rs +++ b/core/src/intrinsics.rs @@ -986,7 +986,7 @@ pub const unsafe fn assume(b: bool) { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] #[rustc_nounwind] -#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)] +#[miri::intrinsic_fallback_is_spec] pub const fn likely(b: bool) -> bool { b } @@ -1006,7 +1006,7 @@ pub const fn likely(b: bool) -> bool { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] #[rustc_nounwind] -#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)] +#[miri::intrinsic_fallback_is_spec] pub const fn unlikely(b: bool) -> bool { b } @@ -2482,7 +2482,7 @@ extern "rust-intrinsic" { #[rustc_nounwind] #[rustc_do_not_const_check] #[inline] -#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)] +#[miri::intrinsic_fallback_is_spec] pub const fn ptr_guaranteed_cmp(ptr: *const T, other: *const T) -> u8 { (ptr == other) as u8 } @@ -2747,7 +2747,7 @@ pub const fn ub_checks() -> bool { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_nounwind] #[rustc_intrinsic] -#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)] +#[miri::intrinsic_fallback_is_spec] pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 { // const eval overrides this function, but runtime code for now just returns null pointers. // See . @@ -2768,7 +2768,7 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_nounwind] #[rustc_intrinsic] -#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)] +#[miri::intrinsic_fallback_is_spec] pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) { // Runtime NOP } @@ -2828,7 +2828,6 @@ impl AggregateRawPtr<*mut T> for *mut P { #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] #[rustc_intrinsic] #[rustc_intrinsic_must_be_overridden] -#[cfg(not(bootstrap))] pub const fn ptr_metadata + ?Sized, M>(_ptr: *const P) -> M { // To implement a fallback we'd have to assume the layout of the pointer, // but the whole point of this intrinsic is that we shouldn't do that. diff --git a/core/src/intrinsics/simd.rs b/core/src/intrinsics/simd.rs index 820f6b2cddc34..4be5e62ea5bc6 100644 --- a/core/src/intrinsics/simd.rs +++ b/core/src/intrinsics/simd.rs @@ -573,7 +573,6 @@ extern "rust-intrinsic" { /// /// `T` must be a vector of integers. #[rustc_nounwind] - #[cfg(not(bootstrap))] pub fn simd_ctpop(x: T) -> T; /// Count the trailing zeros of each element. diff --git a/core/src/iter/traits/collect.rs b/core/src/iter/traits/collect.rs index d9d860c7b6cba..61a457890134c 100644 --- a/core/src/iter/traits/collect.rs +++ b/core/src/iter/traits/collect.rs @@ -311,8 +311,7 @@ where label = "`{Self}` is not an iterator", message = "`{Self}` is not an iterator" )] -#[cfg_attr(bootstrap, rustc_skip_array_during_method_dispatch)] -#[cfg_attr(not(bootstrap), rustc_skip_during_method_dispatch(array, boxed_slice))] +#[rustc_skip_during_method_dispatch(array, boxed_slice)] #[stable(feature = "rust1", since = "1.0.0")] pub trait IntoIterator { /// The type of the elements being iterated over. diff --git a/core/src/num/int_macros.rs b/core/src/num/int_macros.rs index 96510ee4dca60..55bb6166f1017 100644 --- a/core/src/num/int_macros.rs +++ b/core/src/num/int_macros.rs @@ -1165,17 +1165,13 @@ macro_rules! int_impl { #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn unchecked_neg(self) -> Self { - // ICE resolved by #125184 isn't in bootstrap compiler - #[cfg(not(bootstrap))] - { - assert_unsafe_precondition!( - check_language_ub, - concat!(stringify!($SelfT), "::unchecked_neg cannot overflow"), - ( - lhs: $SelfT = self, - ) => !lhs.overflowing_neg().1, - ); - } + assert_unsafe_precondition!( + check_language_ub, + concat!(stringify!($SelfT), "::unchecked_neg cannot overflow"), + ( + lhs: $SelfT = self, + ) => !lhs.overflowing_neg().1, + ); // SAFETY: this is guaranteed to be safe by the caller. unsafe { diff --git a/core/src/ops/async_function.rs b/core/src/ops/async_function.rs index f4e9d1a63ac67..48d1042d9df4a 100644 --- a/core/src/ops/async_function.rs +++ b/core/src/ops/async_function.rs @@ -26,7 +26,7 @@ pub trait AsyncFn: AsyncFnMut { pub trait AsyncFnMut: AsyncFnOnce { /// Future returned by [`AsyncFnMut::async_call_mut`] and [`AsyncFn::async_call`]. #[unstable(feature = "async_fn_traits", issue = "none")] - #[cfg_attr(not(bootstrap), lang = "call_ref_future")] + #[lang = "call_ref_future"] type CallRefFuture<'a>: Future where Self: 'a; @@ -47,12 +47,12 @@ pub trait AsyncFnMut: AsyncFnOnce { pub trait AsyncFnOnce { /// Future returned by [`AsyncFnOnce::async_call_once`]. #[unstable(feature = "async_fn_traits", issue = "none")] - #[cfg_attr(not(bootstrap), lang = "call_once_future")] + #[lang = "call_once_future"] type CallOnceFuture: Future; /// Output type of the called closure's future. #[unstable(feature = "async_fn_traits", issue = "none")] - #[cfg_attr(not(bootstrap), lang = "async_fn_once_output")] + #[lang = "async_fn_once_output"] type Output; /// Call the [`AsyncFnOnce`], returning a future which may move out of the called closure. @@ -146,7 +146,7 @@ mod internal_implementation_detail { // `for<'env> fn() -> (&'env T, ...)`. This allows us to represent the binder // of the closure's self-capture, and these upvar types will be instantiated with // the `'closure_env` region provided to the associated type. - #[cfg_attr(not(bootstrap), lang = "async_fn_kind_upvars")] + #[lang = "async_fn_kind_upvars"] type Upvars<'closure_env, Inputs, Upvars, BorrowedUpvarsAsFnPtr>; } } diff --git a/core/src/ptr/metadata.rs b/core/src/ptr/metadata.rs index 78fe0c5add50b..eb86bf6620652 100644 --- a/core/src/ptr/metadata.rs +++ b/core/src/ptr/metadata.rs @@ -3,7 +3,6 @@ use crate::fmt; use crate::hash::{Hash, Hasher}; use crate::intrinsics::aggregate_raw_ptr; -#[cfg(not(bootstrap))] use crate::intrinsics::ptr_metadata; use crate::marker::Freeze; @@ -96,17 +95,7 @@ pub trait Thin = Pointee; #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] #[inline] pub const fn metadata(ptr: *const T) -> ::Metadata { - #[cfg(bootstrap)] - { - // SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T - // and PtrComponents have the same memory layouts. Only std can make this - // guarantee. - unsafe { PtrRepr { const_ptr: ptr }.components.metadata } - } - #[cfg(not(bootstrap))] - { - ptr_metadata(ptr) - } + ptr_metadata(ptr) } /// Forms a (possibly-wide) raw pointer from a data pointer and metadata. @@ -140,33 +129,6 @@ pub const fn from_raw_parts_mut( aggregate_raw_ptr(data_pointer, metadata) } -#[repr(C)] -#[cfg(bootstrap)] -union PtrRepr { - const_ptr: *const T, - mut_ptr: *mut T, - components: PtrComponents, -} - -#[repr(C)] -#[cfg(bootstrap)] -struct PtrComponents { - data_pointer: *const (), - metadata: ::Metadata, -} - -// Manual impl needed to avoid `T: Copy` bound. -#[cfg(bootstrap)] -impl Copy for PtrComponents {} - -// Manual impl needed to avoid `T: Clone` bound. -#[cfg(bootstrap)] -impl Clone for PtrComponents { - fn clone(&self) -> Self { - *self - } -} - /// The metadata for a `Dyn = dyn SomeTrait` trait object type. /// /// It is a pointer to a vtable (virtual call table) diff --git a/std/src/env.rs b/std/src/env.rs index 4d649f8a6f136..b7b817d97c97e 100644 --- a/std/src/env.rs +++ b/std/src/env.rs @@ -361,20 +361,12 @@ impl Error for VarError { /// } /// assert_eq!(env::var(key), Ok("VALUE".to_string())); /// ``` -#[cfg(not(bootstrap))] #[rustc_deprecated_safe_2024] #[stable(feature = "env", since = "1.0.0")] pub unsafe fn set_var, V: AsRef>(key: K, value: V) { _set_var(key.as_ref(), value.as_ref()) } -#[cfg(bootstrap)] -#[allow(missing_docs)] -#[stable(feature = "env", since = "1.0.0")] -pub fn set_var, V: AsRef>(key: K, value: V) { - unsafe { _set_var(key.as_ref(), value.as_ref()) } -} - unsafe fn _set_var(key: &OsStr, value: &OsStr) { os_imp::setenv(key, value).unwrap_or_else(|e| { panic!("failed to set environment variable `{key:?}` to `{value:?}`: {e}") @@ -434,20 +426,12 @@ unsafe fn _set_var(key: &OsStr, value: &OsStr) { /// } /// assert!(env::var(key).is_err()); /// ``` -#[cfg(not(bootstrap))] #[rustc_deprecated_safe_2024] #[stable(feature = "env", since = "1.0.0")] pub unsafe fn remove_var>(key: K) { _remove_var(key.as_ref()) } -#[cfg(bootstrap)] -#[allow(missing_docs)] -#[stable(feature = "env", since = "1.0.0")] -pub fn remove_var>(key: K) { - unsafe { _remove_var(key.as_ref()) } -} - unsafe fn _remove_var(key: &OsStr) { os_imp::unsetenv(key) .unwrap_or_else(|e| panic!("failed to remove environment variable `{key:?}`: {e}"))