Skip to content

Remove bootstrap cfgs from library/ #141925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ optimize_for_size = ["core/optimize_for_size"]
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(bootstrap)',
'cfg(no_global_oom_handling)',
'cfg(no_rc)',
'cfg(no_sync)',
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
)]
#![doc(cfg_hide(
not(test),
not(any(test, bootstrap)),
no_global_oom_handling,
not(no_global_oom_handling),
not(no_rc),
Expand Down
1 change: 0 additions & 1 deletion library/alloctests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ harness = false
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(bootstrap)',
'cfg(no_global_oom_handling)',
'cfg(no_rc)',
'cfg(no_sync)',
Expand Down
1 change: 0 additions & 1 deletion library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ debug_typeid = []
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(bootstrap)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite this removal, cfg(bootstrap) gets accepted in libcore apparently. However, it now gets rejected for out-of-tree builds, such as https://github.com/rust-lang/miri-test-libstd/. That's bad since it means we'll land changes that then fail to build elsewhere.

I think either the cfg(bootstrap) here should be added back, or our CI needs to ensure that there truly isn't any cfg(bootstrap) in libcore.

Also see https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/Miri.20test-libstd.20Failure.20.282025-06.29/with/522715612

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's troublesome. Sorry, I didn't realize that would happen.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably because bootstrap is still adding the cfg manually to all crates.

/// Extra `--check-cfg` to add when building the compiler or tools
/// (Mode restriction, config name, config values (if any))
#[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above.
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
(None, "bootstrap", None),

'cfg(no_fp_fmt_parse)',
# core use #[path] imports to portable-simd `core_simd` crate
# and to stdarch `core_arch` crate which messes-up with Cargo list
Expand Down
48 changes: 8 additions & 40 deletions library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,38 +413,7 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst<T: Copy>(dst: *mut T, old: T, src:
/// [`atomic`] types via the `load` method. For example, [`AtomicBool::load`].
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg(not(bootstrap))]
pub unsafe fn atomic_load<T: Copy, const ORD: AtomicOrdering>(src: *const T) -> T;
/// Loads the current value of the pointer.
/// `T` must be an integer or pointer type.
///
/// The stabilized version of this intrinsic is available on the
/// [`atomic`] types via the `load` method by passing
/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::load`].
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg(bootstrap)]
pub unsafe fn atomic_load_seqcst<T: Copy>(src: *const T) -> T;
/// Loads the current value of the pointer.
/// `T` must be an integer or pointer type.
///
/// The stabilized version of this intrinsic is available on the
/// [`atomic`] types via the `load` method by passing
/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::load`].
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg(bootstrap)]
pub unsafe fn atomic_load_acquire<T: Copy>(src: *const T) -> T;
/// Loads the current value of the pointer.
/// `T` must be an integer or pointer type.
///
/// The stabilized version of this intrinsic is available on the
/// [`atomic`] types via the `load` method by passing
/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`].
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg(bootstrap)]
pub unsafe fn atomic_load_relaxed<T: Copy>(src: *const T) -> T;

/// Stores the value at the specified memory location.
/// `T` must be an integer or pointer type.
Expand Down Expand Up @@ -1767,7 +1736,6 @@ pub const unsafe fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
/// - `index < PtrMetadata(slice_ptr)`, so the indexing is in-bounds for the slice
/// - the resulting offsetting is in-bounds of the allocated object, which is
/// always the case for references, but needs to be upheld manually for pointers
#[cfg(not(bootstrap))]
#[rustc_nounwind]
#[rustc_intrinsic]
pub const unsafe fn slice_get_unchecked<
Expand Down Expand Up @@ -3710,7 +3678,7 @@ pub const fn minnumf128(x: f128, y: f128) -> f128;
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn minimumf16(x: f16, y: f16) -> f16 {
if x < y {
x
Expand All @@ -3731,7 +3699,7 @@ pub const fn minimumf16(x: f16, y: f16) -> f16 {
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn minimumf32(x: f32, y: f32) -> f32 {
if x < y {
x
Expand All @@ -3752,7 +3720,7 @@ pub const fn minimumf32(x: f32, y: f32) -> f32 {
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn minimumf64(x: f64, y: f64) -> f64 {
if x < y {
x
Expand All @@ -3773,7 +3741,7 @@ pub const fn minimumf64(x: f64, y: f64) -> f64 {
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn minimumf128(x: f128, y: f128) -> f128 {
if x < y {
x
Expand Down Expand Up @@ -3848,7 +3816,7 @@ pub const fn maxnumf128(x: f128, y: f128) -> f128;
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn maximumf16(x: f16, y: f16) -> f16 {
if x > y {
x
Expand All @@ -3868,7 +3836,7 @@ pub const fn maximumf16(x: f16, y: f16) -> f16 {
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn maximumf32(x: f32, y: f32) -> f32 {
if x > y {
x
Expand All @@ -3888,7 +3856,7 @@ pub const fn maximumf32(x: f32, y: f32) -> f32 {
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn maximumf64(x: f64, y: f64) -> f64 {
if x > y {
x
Expand All @@ -3908,7 +3876,7 @@ pub const fn maximumf64(x: f64, y: f64) -> f64 {
/// Therefore, implementations must not require the user to uphold
/// any safety invariants.
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub const fn maximumf128(x: f128, y: f128) -> f128 {
if x > y {
x
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
//
// Target features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(avx512_target_feature))]
#![feature(aarch64_unstable_target_feature)]
#![feature(arm_target_feature)]
#![feature(hexagon_target_feature)]
Expand Down Expand Up @@ -225,7 +224,6 @@ pub mod assert_matches {

// We don't export this through #[macro_export] for now, to avoid breakage.
#[unstable(feature = "autodiff", issue = "124509")]
#[cfg(not(bootstrap))]
/// Unstable module containing the unstable `autodiff` macro.
pub mod autodiff {
#[unstable(feature = "autodiff", issue = "124509")]
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,6 @@ pub(crate) mod builtin {
#[unstable(feature = "autodiff", issue = "124509")]
#[allow_internal_unstable(rustc_attrs)]
#[rustc_builtin_macro]
#[cfg(not(bootstrap))]
pub macro autodiff_forward($item:item) {
/* compiler built-in */
}
Expand All @@ -1552,7 +1551,6 @@ pub(crate) mod builtin {
#[unstable(feature = "autodiff", issue = "124509")]
#[allow_internal_unstable(rustc_attrs)]
#[rustc_builtin_macro]
#[cfg(not(bootstrap))]
pub macro autodiff_reverse($item:item) {
/* compiler built-in */
}
Expand Down
1 change: 0 additions & 1 deletion library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,6 @@ pub use self::unsafe_pinned::UnsafePinned;
#[rustc_pub_transparent]
#[derive(Copy, Clone)]
pub struct Pin<Ptr> {
/// Only public for bootstrap.
pointer: Ptr,
}

Expand Down
57 changes: 4 additions & 53 deletions library/core/src/slice/index.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Indexing implementations for `[T]`.

#[cfg(not(bootstrap))]
use crate::intrinsics::slice_get_unchecked;
use crate::panic::const_panic;
use crate::ub_checks::assert_unsafe_precondition;
Expand Down Expand Up @@ -85,22 +84,6 @@ const fn slice_end_index_overflow_fail() -> ! {
// Both the safe and unsafe public methods share these helpers,
// which use intrinsics directly to get *no* extra checks.

#[cfg(bootstrap)]
#[inline(always)]
const unsafe fn get_noubcheck<T>(ptr: *const [T], index: usize) -> *const T {
let ptr = ptr as *const T;
// SAFETY: The caller already checked these preconditions
unsafe { crate::intrinsics::offset(ptr, index) }
}

#[cfg(bootstrap)]
#[inline(always)]
const unsafe fn get_mut_noubcheck<T>(ptr: *mut [T], index: usize) -> *mut T {
let ptr = ptr as *mut T;
// SAFETY: The caller already checked these preconditions
unsafe { crate::intrinsics::offset(ptr, index) }
}

#[inline(always)]
const unsafe fn get_offset_len_noubcheck<T>(
ptr: *const [T],
Expand Down Expand Up @@ -231,16 +214,8 @@ unsafe impl<T> SliceIndex<[T]> for usize {
#[inline]
fn get(self, slice: &[T]) -> Option<&T> {
if self < slice.len() {
#[cfg(bootstrap)]
// SAFETY: `self` is checked to be in bounds.
unsafe {
Some(&*get_noubcheck(slice, self))
}
#[cfg(not(bootstrap))]
// SAFETY: `self` is checked to be in bounds.
unsafe {
Some(slice_get_unchecked(slice, self))
}
unsafe { Some(slice_get_unchecked(slice, self)) }
} else {
None
}
Expand All @@ -249,16 +224,8 @@ unsafe impl<T> SliceIndex<[T]> for usize {
#[inline]
fn get_mut(self, slice: &mut [T]) -> Option<&mut T> {
if self < slice.len() {
#[cfg(bootstrap)]
// SAFETY: `self` is checked to be in bounds.
unsafe {
Some(&mut *get_mut_noubcheck(slice, self))
}
#[cfg(not(bootstrap))]
// SAFETY: `self` is checked to be in bounds.
unsafe {
Some(slice_get_unchecked(slice, self))
}
unsafe { Some(slice_get_unchecked(slice, self)) }
} else {
None
}
Expand All @@ -280,14 +247,7 @@ unsafe impl<T> SliceIndex<[T]> for usize {
// Use intrinsics::assume instead of hint::assert_unchecked so that we don't check the
// precondition of this function twice.
crate::intrinsics::assume(self < slice.len());
#[cfg(bootstrap)]
{
get_noubcheck(slice, self)
}
#[cfg(not(bootstrap))]
{
slice_get_unchecked(slice, self)
}
slice_get_unchecked(slice, self)
}
}

Expand All @@ -300,16 +260,7 @@ unsafe impl<T> SliceIndex<[T]> for usize {
(this: usize = self, len: usize = slice.len()) => this < len
);
// SAFETY: see comments for `get_unchecked` above.
unsafe {
#[cfg(bootstrap)]
{
get_mut_noubcheck(slice, self)
}
#[cfg(not(bootstrap))]
{
slice_get_unchecked(slice, self)
}
}
unsafe { slice_get_unchecked(slice, self) }
}

#[inline]
Expand Down
17 changes: 0 additions & 17 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3822,23 +3822,6 @@ unsafe fn atomic_store<T: Copy>(dst: *mut T, val: T, order: Ordering) {

#[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
#[cfg(bootstrap)]
unsafe fn atomic_load<T: Copy>(dst: *const T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_load`.
unsafe {
match order {
Relaxed => intrinsics::atomic_load_relaxed(dst),
Acquire => intrinsics::atomic_load_acquire(dst),
SeqCst => intrinsics::atomic_load_seqcst(dst),
Release => panic!("there is no such thing as a release load"),
AcqRel => panic!("there is no such thing as an acquire-release load"),
}
}
}

#[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
#[cfg(not(bootstrap))]
unsafe fn atomic_load<T: Copy>(dst: *const T, order: Ordering) -> T {
use intrinsics::AtomicOrdering;
// SAFETY: the caller must uphold the safety contract for `atomic_load`.
Expand Down
6 changes: 0 additions & 6 deletions library/coretests/tests/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,6 @@ macro_rules! test_float {
assert!(<$fty>::NAN.div_euclid(<$fty>::INFINITY).is_nan());
}
#[test]
#[cfg(not(bootstrap))]
fn floor() {
$fassert!((0.0 as $fty).floor(), 0.0);
$fassert!((0.0 as $fty).floor().is_sign_positive());
Expand All @@ -969,7 +968,6 @@ macro_rules! test_float {
$fassert!(<$fty>::NEG_INFINITY.floor(), <$fty>::NEG_INFINITY);
}
#[test]
#[cfg(not(bootstrap))]
fn ceil() {
$fassert!((0.0 as $fty).ceil(), 0.0);
$fassert!((0.0 as $fty).ceil().is_sign_positive());
Expand All @@ -986,7 +984,6 @@ macro_rules! test_float {
$fassert!(<$fty>::NEG_INFINITY.ceil(), <$fty>::NEG_INFINITY);
}
#[test]
#[cfg(not(bootstrap))]
fn round() {
$fassert!((0.0 as $fty).round(), 0.0);
$fassert!((0.0 as $fty).round().is_sign_positive());
Expand All @@ -1003,7 +1000,6 @@ macro_rules! test_float {
$fassert!(<$fty>::NEG_INFINITY.round(), <$fty>::NEG_INFINITY);
}
#[test]
#[cfg(not(bootstrap))]
fn round_ties_even() {
$fassert!((0.0 as $fty).round_ties_even(), 0.0);
$fassert!((0.0 as $fty).round_ties_even().is_sign_positive());
Expand All @@ -1022,7 +1018,6 @@ macro_rules! test_float {
$fassert!(<$fty>::NEG_INFINITY.round_ties_even(), <$fty>::NEG_INFINITY);
}
#[test]
#[cfg(not(bootstrap))]
fn trunc() {
$fassert!((0.0 as $fty).trunc(), 0.0);
$fassert!((0.0 as $fty).trunc().is_sign_positive());
Expand All @@ -1041,7 +1036,6 @@ macro_rules! test_float {
$fassert!(<$fty>::NEG_INFINITY.trunc(), <$fty>::NEG_INFINITY);
}
#[test]
#[cfg(not(bootstrap))]
fn fract() {
$fassert!((0.0 as $fty).fract(), 0.0);
$fassert!((0.0 as $fty).fract().is_sign_positive());
Expand Down
1 change: 0 additions & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ test = true
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(bootstrap)',
# std use #[path] imports to portable-simd `std_float` crate
# and to the `backtrace` crate which messes-up with Cargo list
# of declared features, we therefor expect any feature cfg
Expand Down
Loading
Loading