Skip to content

Commit

Permalink
remove cfg(bootstrap)
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Jun 11, 2024
1 parent a2ff49b commit d8fe589
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 84 deletions.
3 changes: 1 addition & 2 deletions alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down
1 change: 0 additions & 1 deletion alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
1 change: 0 additions & 1 deletion core/src/future/async_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ async unsafe fn either<O: IntoFuture<Output = ()>, M: IntoFuture<Output = ()>, T
}
}

#[cfg(not(bootstrap))]
#[lang = "async_drop_deferred_drop_in_place"]
async unsafe fn deferred_drop_in_place<T>(to_drop: *mut T) {
// SAFETY: same safety requirements as with drop_in_place (implied by
Expand Down
2 changes: 1 addition & 1 deletion core/src/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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<T>(ptr: *const T, other: *const T) -> u8 {
(ptr == other) as u8
}
Expand Down Expand Up @@ -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 <https://github.com/rust-lang/rust/issues/93935>.
Expand All @@ -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
}
Expand Down Expand Up @@ -2828,7 +2828,6 @@ impl<P: ?Sized, T: ptr::Thin> 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<P: ptr::Pointee<Metadata = M> + ?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.
Expand Down
1 change: 0 additions & 1 deletion core/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ extern "rust-intrinsic" {
///
/// `T` must be a vector of integers.
#[rustc_nounwind]
#[cfg(not(bootstrap))]
pub fn simd_ctpop<T>(x: T) -> T;

/// Count the trailing zeros of each element.
Expand Down
3 changes: 1 addition & 2 deletions core/src/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 7 additions & 11 deletions core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions core/src/ops/async_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub trait AsyncFn<Args: Tuple>: AsyncFnMut<Args> {
pub trait AsyncFnMut<Args: Tuple>: AsyncFnOnce<Args> {
/// 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<Output = Self::Output>
where
Self: 'a;
Expand All @@ -47,12 +47,12 @@ pub trait AsyncFnMut<Args: Tuple>: AsyncFnOnce<Args> {
pub trait AsyncFnOnce<Args: Tuple> {
/// 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 = Self::Output>;

/// 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.
Expand Down Expand Up @@ -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>;
}
}
40 changes: 1 addition & 39 deletions core/src/ptr/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -96,17 +95,7 @@ pub trait Thin = Pointee<Metadata = ()>;
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
#[inline]
pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
#[cfg(bootstrap)]
{
// 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 { 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.
Expand Down Expand Up @@ -140,33 +129,6 @@ pub const fn from_raw_parts_mut<T: ?Sized>(
aggregate_raw_ptr(data_pointer, metadata)
}

#[repr(C)]
#[cfg(bootstrap)]
union PtrRepr<T: ?Sized> {
const_ptr: *const T,
mut_ptr: *mut T,
components: PtrComponents<T>,
}

#[repr(C)]
#[cfg(bootstrap)]
struct PtrComponents<T: ?Sized> {
data_pointer: *const (),
metadata: <T as Pointee>::Metadata,
}

// Manual impl needed to avoid `T: Copy` bound.
#[cfg(bootstrap)]
impl<T: ?Sized> Copy for PtrComponents<T> {}

// Manual impl needed to avoid `T: Clone` bound.
#[cfg(bootstrap)]
impl<T: ?Sized> Clone for PtrComponents<T> {
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)
Expand Down
16 changes: 0 additions & 16 deletions std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K: AsRef<OsStr>, V: AsRef<OsStr>>(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<K: AsRef<OsStr>, V: AsRef<OsStr>>(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}")
Expand Down Expand Up @@ -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<K: AsRef<OsStr>>(key: K) {
_remove_var(key.as_ref())
}

#[cfg(bootstrap)]
#[allow(missing_docs)]
#[stable(feature = "env", since = "1.0.0")]
pub fn remove_var<K: AsRef<OsStr>>(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}"))
Expand Down

0 comments on commit d8fe589

Please sign in to comment.