step cfgs

This commit is contained in:
Mark Rousskov 2024-03-19 09:34:31 -04:00
parent e4c58eb8da
commit 02f1930595
35 changed files with 50 additions and 205 deletions

View File

@ -16,7 +16,6 @@
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(let_chains)] #![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(never_type)] #![feature(never_type)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(stmt_expr_attributes)] #![feature(stmt_expr_attributes)]

View File

@ -7,7 +7,6 @@
#![allow(internal_features)] #![allow(internal_features)]
#![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)] #![allow(rustc::untranslatable_diagnostic)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(array_windows)] #![feature(array_windows)]

View File

@ -5,7 +5,6 @@
#![feature(associated_type_defaults)] #![feature(associated_type_defaults)]
#![feature(closure_track_caller)] #![feature(closure_track_caller)]
#![feature(let_chains)] #![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(never_type)] #![feature(never_type)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(variant_count)] #![feature(variant_count)]

View File

@ -68,7 +68,6 @@ This API is completely unstable and subject to change.
#![feature(is_sorted)] #![feature(is_sorted)]
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(let_chains)] #![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(never_type)] #![feature(never_type)]
#![feature(lazy_cell)] #![feature(lazy_cell)]
#![feature(slice_partition_dedup)] #![feature(slice_partition_dedup)]

View File

@ -5,7 +5,6 @@
#![feature(try_blocks)] #![feature(try_blocks)]
#![feature(never_type)] #![feature(never_type)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(control_flow_enum)] #![feature(control_flow_enum)]
#[macro_use] #[macro_use]

View File

@ -25,7 +25,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(iterator_try_collect)] #![feature(iterator_try_collect)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(try_blocks)] #![feature(try_blocks)]
#![recursion_limit = "512"] // For rustdoc #![recursion_limit = "512"] // For rustdoc

View File

@ -24,8 +24,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)] #![doc(rust_logo)]
#![cfg_attr(bootstrap, feature(exhaustive_patterns))] #![feature(min_exhaustive_patterns)]
#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(array_windows)] #![feature(array_windows)]

View File

@ -9,7 +9,6 @@
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(let_chains)] #![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(try_blocks)] #![feature(try_blocks)]
#[macro_use] #[macro_use]

View File

@ -2,7 +2,6 @@
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
#![feature(let_chains)] #![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(try_blocks)] #![feature(try_blocks)]
#[macro_use] #[macro_use]

View File

@ -8,7 +8,6 @@
#![feature(is_sorted)] #![feature(is_sorted)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(map_try_insert)] #![feature(map_try_insert)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(never_type)] #![feature(never_type)]
#![feature(option_get_or_insert_default)] #![feature(option_get_or_insert_default)]
#![feature(round_char_boundary)] #![feature(round_char_boundary)]

View File

@ -9,13 +9,11 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)] #![doc(rust_logo)]
#![cfg_attr(bootstrap, feature(exhaustive_patterns))] #![feature(min_exhaustive_patterns)]
#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(assert_matches)] #![feature(assert_matches)]
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(let_chains)] #![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(step_trait)] #![feature(step_trait)]
#![allow(internal_features)] #![allow(internal_features)]

View File

@ -26,7 +26,6 @@
#![feature(option_take_if)] #![feature(option_take_if)]
#![feature(never_type)] #![feature(never_type)]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![recursion_limit = "512"] // For rustdoc #![recursion_limit = "512"] // For rustdoc
#[macro_use] #[macro_use]

View File

@ -51,7 +51,7 @@ extern "Rust" {
#[derive(Copy, Clone, Default, Debug)] #[derive(Copy, Clone, Default, Debug)]
#[cfg(not(test))] #[cfg(not(test))]
// the compiler needs to know when a Box uses the global allocator vs a custom one // the compiler needs to know when a Box uses the global allocator vs a custom one
#[cfg_attr(not(bootstrap), lang = "global_alloc_ty")] #[lang = "global_alloc_ty"]
pub struct Global; pub struct Global;
#[cfg(test)] #[cfg(test)]
@ -387,8 +387,7 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
} }
#[cfg(not(feature = "panic_immediate_abort"))] #[cfg(not(feature = "panic_immediate_abort"))]
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block {
unsafe {
core::intrinsics::const_eval_select((layout,), ct_error, rt_error) core::intrinsics::const_eval_select((layout,), ct_error, rt_error)
} }

View File

@ -396,7 +396,7 @@ pub trait AsMut<T: ?Sized> {
/// For example, take this code: /// For example, take this code:
/// ///
/// ``` /// ```
/// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))] /// # #![allow(non_local_definitions)]
/// struct Wrapper<T>(Vec<T>); /// struct Wrapper<T>(Vec<T>);
/// impl<T> From<Wrapper<T>> for Vec<T> { /// impl<T> From<Wrapper<T>> for Vec<T> {
/// fn from(w: Wrapper<T>) -> Vec<T> { /// fn from(w: Wrapper<T>) -> Vec<T> {

View File

@ -438,13 +438,7 @@ impl CStr {
unsafe { &*(bytes as *const [u8] as *const CStr) } unsafe { &*(bytes as *const [u8] as *const CStr) }
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block intrinsics::const_eval_select((bytes,), const_impl, rt_impl)
// SAFETY: The const and runtime versions have identical behavior
// unless the safety contract of `from_bytes_with_nul_unchecked` is
// violated, which is UB.
unsafe {
intrinsics::const_eval_select((bytes,), const_impl, rt_impl)
}
} }
/// Returns the inner pointer to this C string. /// Returns the inner pointer to this C string.
@ -759,11 +753,7 @@ const unsafe fn const_strlen(ptr: *const c_char) -> usize {
unsafe { strlen(s) } unsafe { strlen(s) }
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block intrinsics::const_eval_select((ptr,), strlen_ct, strlen_rt)
// SAFETY: the two functions always provide equivalent functionality
unsafe {
intrinsics::const_eval_select((ptr,), strlen_ct, strlen_rt)
}
} }
/// An iterator over the bytes of a [`CStr`], without the nul terminator. /// An iterator over the bytes of a [`CStr`], without the nul terminator.

View File

@ -454,7 +454,7 @@ pub trait Hasher {
/// ``` /// ```
/// #![feature(hasher_prefixfree_extras)] /// #![feature(hasher_prefixfree_extras)]
/// # // Stubs to make the `impl` below pass the compiler /// # // Stubs to make the `impl` below pass the compiler
/// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))] /// # #![allow(non_local_definitions)]
/// # struct MyCollection<T>(Option<T>); /// # struct MyCollection<T>(Option<T>);
/// # impl<T> MyCollection<T> { /// # impl<T> MyCollection<T> {
/// # fn len(&self) -> usize { todo!() } /// # fn len(&self) -> usize { todo!() }

View File

@ -84,9 +84,6 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
unsafe { crate::ptr::drop_in_place(to_drop) } unsafe { crate::ptr::drop_in_place(to_drop) }
} }
#[cfg(bootstrap)]
pub use self::r#try as catch_unwind;
extern "rust-intrinsic" { extern "rust-intrinsic" {
// N.B., these intrinsics take raw pointers because they mutate aliased // N.B., these intrinsics take raw pointers because they mutate aliased
// memory, which is not valid for either `&` or `&mut`. // memory, which is not valid for either `&` or `&mut`.
@ -965,8 +962,7 @@ extern "rust-intrinsic" {
#[rustc_const_stable(feature = "const_assume", since = "1.77.0")] #[rustc_const_stable(feature = "const_assume", since = "1.77.0")]
#[rustc_nounwind] #[rustc_nounwind]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
#[cfg_attr(bootstrap, inline)]
pub const unsafe fn assume(b: bool) { pub const unsafe fn assume(b: bool) {
if !b { if !b {
// SAFETY: the caller must guarantee the argument is never `false` // SAFETY: the caller must guarantee the argument is never `false`
@ -987,9 +983,8 @@ pub const unsafe fn assume(b: bool) {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature = "const_likely", issue = "none")] #[rustc_const_unstable(feature = "const_likely", issue = "none")]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg_attr(bootstrap, inline)]
pub const fn likely(b: bool) -> bool { pub const fn likely(b: bool) -> bool {
b b
} }
@ -1007,9 +1002,8 @@ pub const fn likely(b: bool) -> bool {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature = "const_likely", issue = "none")] #[rustc_const_unstable(feature = "const_likely", issue = "none")]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg_attr(bootstrap, inline)]
pub const fn unlikely(b: bool) -> bool { pub const fn unlikely(b: bool) -> bool {
b b
} }
@ -1919,7 +1913,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_nounwind] #[rustc_nounwind]
#[rustc_safe_intrinsic] #[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fadd_algebraic<T: Copy>(a: T, b: T) -> T; pub fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float subtraction that allows optimizations based on algebraic rules. /// Float subtraction that allows optimizations based on algebraic rules.
@ -1927,7 +1920,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_nounwind] #[rustc_nounwind]
#[rustc_safe_intrinsic] #[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fsub_algebraic<T: Copy>(a: T, b: T) -> T; pub fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float multiplication that allows optimizations based on algebraic rules. /// Float multiplication that allows optimizations based on algebraic rules.
@ -1935,7 +1927,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_nounwind] #[rustc_nounwind]
#[rustc_safe_intrinsic] #[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fmul_algebraic<T: Copy>(a: T, b: T) -> T; pub fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float division that allows optimizations based on algebraic rules. /// Float division that allows optimizations based on algebraic rules.
@ -1943,7 +1934,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_nounwind] #[rustc_nounwind]
#[rustc_safe_intrinsic] #[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T; pub fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float remainder that allows optimizations based on algebraic rules. /// Float remainder that allows optimizations based on algebraic rules.
@ -1951,7 +1941,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart. /// This intrinsic does not have a stable counterpart.
#[rustc_nounwind] #[rustc_nounwind]
#[rustc_safe_intrinsic] #[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn frem_algebraic<T: Copy>(a: T, b: T) -> T; pub fn frem_algebraic<T: Copy>(a: T, b: T) -> T;
/// Convert with LLVMs fptoui/fptosi, which may return undef for values out of range /// Convert with LLVMs fptoui/fptosi, which may return undef for values out of range
@ -2407,14 +2396,8 @@ extern "rust-intrinsic" {
/// ///
/// The stable version of this intrinsic is `std::panic::catch_unwind`. /// The stable version of this intrinsic is `std::panic::catch_unwind`.
#[rustc_nounwind] #[rustc_nounwind]
#[cfg(not(bootstrap))]
pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
/// For bootstrap only, see `catch_unwind`.
#[rustc_nounwind]
#[cfg(bootstrap)]
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
/// Emits a `!nontemporal` store according to LLVM (see their docs). /// Emits a `!nontemporal` store according to LLVM (see their docs).
/// Probably will never become stable. /// Probably will never become stable.
/// ///
@ -2518,9 +2501,9 @@ extern "rust-intrinsic" {
#[cfg(bootstrap)] #[cfg(bootstrap)]
pub fn vtable_align(ptr: *const ()) -> usize; pub fn vtable_align(ptr: *const ()) -> usize;
#[cfg(bootstrap)]
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")] #[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)] #[rustc_safe_intrinsic]
#[cfg(bootstrap)]
pub fn const_eval_select<ARG: Tuple, F, G, RET>( pub fn const_eval_select<ARG: Tuple, F, G, RET>(
arg: ARG, arg: ARG,
called_in_const: F, called_in_const: F,
@ -2650,8 +2633,7 @@ where
#[rustc_const_unstable(feature = "is_val_statically_known", issue = "none")] #[rustc_const_unstable(feature = "is_val_statically_known", issue = "none")]
#[rustc_nounwind] #[rustc_nounwind]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
#[cfg_attr(bootstrap, inline)]
pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool { pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
false false
} }
@ -2670,7 +2652,7 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
#[rustc_const_unstable(feature = "ub_checks", issue = "none")] #[rustc_const_unstable(feature = "ub_checks", issue = "none")]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[inline(always)] #[inline(always)]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
pub(crate) const fn check_library_ub() -> bool { pub(crate) const fn check_library_ub() -> bool {
cfg!(debug_assertions) cfg!(debug_assertions)
} }
@ -2686,7 +2668,7 @@ pub(crate) const fn check_library_ub() -> bool {
#[rustc_const_unstable(feature = "ub_checks", issue = "none")] #[rustc_const_unstable(feature = "ub_checks", issue = "none")]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[inline(always)] #[inline(always)]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
pub(crate) const fn check_language_ub() -> bool { pub(crate) const fn check_language_ub() -> bool {
cfg!(debug_assertions) cfg!(debug_assertions)
} }
@ -2702,8 +2684,7 @@ pub(crate) const fn check_language_ub() -> bool {
#[rustc_const_unstable(feature = "const_heap", issue = "79597")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
#[cfg_attr(bootstrap, inline)]
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 { pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
// const eval overrides this function, but runtime code should always just return null pointers. // const eval overrides this function, but runtime code should always just return null pointers.
crate::ptr::null_mut() crate::ptr::null_mut()
@ -2722,8 +2703,7 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
#[rustc_const_unstable(feature = "const_heap", issue = "79597")] #[rustc_const_unstable(feature = "const_heap", issue = "79597")]
#[unstable(feature = "core_intrinsics", issue = "none")] #[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_nounwind] #[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)] #[rustc_intrinsic]
#[cfg_attr(bootstrap, inline)]
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {} pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
/// `ptr` must point to a vtable. /// `ptr` must point to a vtable.
@ -2799,15 +2779,6 @@ pub unsafe fn vtable_align(_ptr: *const ()) -> usize {
macro_rules! assert_unsafe_precondition { macro_rules! assert_unsafe_precondition {
($kind:ident, $message:expr, ($($name:ident:$ty:ty = $arg:expr),*$(,)?) => $e:expr $(,)?) => { ($kind:ident, $message:expr, ($($name:ident:$ty:ty = $arg:expr),*$(,)?) => $e:expr $(,)?) => {
{ {
// #[cfg(bootstrap)] (this comment)
// When the standard library is compiled with debug assertions, we want the check to inline for better performance.
// This is important when working on the compiler, which is compiled with debug assertions locally.
// When not compiled with debug assertions (so the precompiled std) we outline the check to minimize the compile
// time impact when debug assertions are disabled.
// The proper solution to this is the `#[rustc_no_mir_inline]` below, but we still want decent performance for cfg(bootstrap).
#[cfg_attr(all(debug_assertions, bootstrap), inline(always))]
#[cfg_attr(all(not(debug_assertions), bootstrap), inline(never))]
// This check is inlineable, but not by the MIR inliner. // This check is inlineable, but not by the MIR inliner.
// The reason for this is that the MIR inliner is in an exceptionally bad position // The reason for this is that the MIR inliner is in an exceptionally bad position
// to think about whether or not to inline this. In MIR, this call is gated behind `debug_assertions`, // to think about whether or not to inline this. In MIR, this call is gated behind `debug_assertions`,
@ -2816,8 +2787,8 @@ macro_rules! assert_unsafe_precondition {
// //
// LLVM on the other hand sees the constant branch, so if it's `false`, it can immediately delete it without // LLVM on the other hand sees the constant branch, so if it's `false`, it can immediately delete it without
// inlining the check. If it's `true`, it can inline it and get significantly better performance. // inlining the check. If it's `true`, it can inline it and get significantly better performance.
#[cfg_attr(not(bootstrap), rustc_no_mir_inline)] #[rustc_no_mir_inline]
#[cfg_attr(not(bootstrap), inline)] #[inline]
#[rustc_nounwind] #[rustc_nounwind]
#[rustc_const_unstable(feature = "ub_checks", issue = "none")] #[rustc_const_unstable(feature = "ub_checks", issue = "none")]
const fn precondition_check($($name:$ty),*) { const fn precondition_check($($name:$ty),*) {
@ -2885,13 +2856,7 @@ pub(crate) const fn is_nonoverlapping(
true true
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((src, dst, size, count), comptime, runtime)
// SAFETY: This function's precondition is equivalent to that of `const_eval_select`.
// Programs which do not execute UB will only see this function return `true`, which makes the
// const and runtime implementation indistinguishable.
unsafe {
const_eval_select((src, dst, size, count), comptime, runtime)
}
} }
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source /// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
@ -3208,9 +3173,5 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize
const fn compiletime(_ptr: *const (), _align: usize) {} const fn compiletime(_ptr: *const (), _align: usize) {}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((ptr, align), compiletime, runtime);
// SAFETY: the extra behavior at runtime is for UB checks only.
unsafe {
const_eval_select((ptr, align), compiletime, runtime);
}
} }

View File

@ -2,11 +2,7 @@
//! //!
//! In this module, a "vector" is any `repr(simd)` type. //! In this module, a "vector" is any `repr(simd)` type.
// Temporary macro while we switch the ABI from "platform-intrinsics" to "intrinsics". extern "rust-intrinsic" {
#[rustfmt::skip]
macro_rules! declare_intrinsics {
($abi:tt) => {
extern $abi {
/// Insert an element into a vector, returning the updated vector. /// Insert an element into a vector, returning the updated vector.
/// ///
/// `T` must be a vector with element type `U`. /// `T` must be a vector with element type `U`.
@ -659,10 +655,3 @@ extern $abi {
#[rustc_nounwind] #[rustc_nounwind]
pub fn simd_flog<T>(a: T) -> T; pub fn simd_flog<T>(a: T) -> T;
} }
}
}
#[cfg(bootstrap)]
declare_intrinsics!("platform-intrinsic");
#[cfg(not(bootstrap))]
declare_intrinsics!("rust-intrinsic");

View File

@ -112,6 +112,7 @@
// //
// Library features: // Library features:
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![feature(array_ptr_get)] #![feature(array_ptr_get)]
#![feature(char_indices_offset)] #![feature(char_indices_offset)]
#![feature(const_align_of_val)] #![feature(const_align_of_val)]
@ -203,12 +204,6 @@
// //
// Language features: // Language features:
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![cfg_attr(bootstrap, feature(diagnostic_namespace))]
#![cfg_attr(bootstrap, feature(exhaustive_patterns))]
#![cfg_attr(bootstrap, feature(platform_intrinsics))]
#![cfg_attr(not(bootstrap), feature(freeze_impls))]
#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))]
#![feature(abi_unadjusted)] #![feature(abi_unadjusted)]
#![feature(adt_const_params)] #![feature(adt_const_params)]
#![feature(allow_internal_unsafe)] #![feature(allow_internal_unsafe)]
@ -233,6 +228,7 @@
#![feature(doc_notable_trait)] #![feature(doc_notable_trait)]
#![feature(effects)] #![feature(effects)]
#![feature(extern_types)] #![feature(extern_types)]
#![feature(freeze_impls)]
#![feature(fundamental)] #![feature(fundamental)]
#![feature(generic_arg_infer)] #![feature(generic_arg_infer)]
#![feature(if_let_guard)] #![feature(if_let_guard)]
@ -243,6 +239,7 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(link_llvm_intrinsics)] #![feature(link_llvm_intrinsics)]
#![feature(macro_metavar_expr)] #![feature(macro_metavar_expr)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(multiple_supertrait_upcastable)] #![feature(multiple_supertrait_upcastable)]
#![feature(must_not_suspend)] #![feature(must_not_suspend)]

View File

@ -6,7 +6,7 @@ use crate::marker::ConstParamTy;
/// any value of type `Self` are safely transmutable into a value of type `Dst`, in a given `Context`, /// any value of type `Self` are safely transmutable into a value of type `Dst`, in a given `Context`,
/// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied. /// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied.
#[unstable(feature = "transmutability", issue = "99571")] #[unstable(feature = "transmutability", issue = "99571")]
#[cfg_attr(not(bootstrap), lang = "transmute_trait")] #[lang = "transmute_trait"]
#[rustc_deny_explicit_impl(implement_via_object = false)] #[rustc_deny_explicit_impl(implement_via_object = false)]
#[rustc_coinductive] #[rustc_coinductive]
pub unsafe trait BikeshedIntrinsicFrom<Src, const ASSUME: Assume = { Assume::NOTHING }> pub unsafe trait BikeshedIntrinsicFrom<Src, const ASSUME: Assume = { Assume::NOTHING }>

View File

@ -1153,11 +1153,7 @@ impl f32 {
// Stability concerns. // Stability concerns.
unsafe { mem::transmute(x) } unsafe { mem::transmute(x) }
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32)
// SAFETY: We use internal implementations that either always work or fail at compile time.
unsafe {
intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32)
}
} }
/// Raw transmutation from `u32`. /// Raw transmutation from `u32`.
@ -1248,11 +1244,7 @@ impl f32 {
// Stability concerns. // Stability concerns.
unsafe { mem::transmute(x) } unsafe { mem::transmute(x) }
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block intrinsics::const_eval_select((v,), ct_u32_to_f32, rt_u32_to_f32)
// SAFETY: We use internal implementations that either always work or fail at compile time.
unsafe {
intrinsics::const_eval_select((v,), ct_u32_to_f32, rt_u32_to_f32)
}
} }
/// Return the memory representation of this floating point number as a byte array in /// Return the memory representation of this floating point number as a byte array in

View File

@ -1146,11 +1146,7 @@ impl f64 {
// Stability concerns. // Stability concerns.
unsafe { mem::transmute::<f64, u64>(rt) } unsafe { mem::transmute::<f64, u64>(rt) }
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64)
// SAFETY: We use internal implementations that either always work or fail at compile time.
unsafe {
intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64)
}
} }
/// Raw transmutation from `u64`. /// Raw transmutation from `u64`.
@ -1246,11 +1242,7 @@ impl f64 {
// Stability concerns. // Stability concerns.
unsafe { mem::transmute::<u64, f64>(rt) } unsafe { mem::transmute::<u64, f64>(rt) }
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block intrinsics::const_eval_select((v,), ct_u64_to_f64, rt_u64_to_f64)
// SAFETY: We use internal implementations that either always work or fail at compile time.
unsafe {
intrinsics::const_eval_select((v,), ct_u64_to_f64, rt_u64_to_f64)
}
} }
/// Return the memory representation of this floating point number as a byte array in /// Return the memory representation of this floating point number as a byte array in

View File

@ -140,7 +140,7 @@ mod internal_implementation_detail {
/// and thus either `?0` or `i8`/`i16`/`i32` (see docs for `ClosureKind` /// and thus either `?0` or `i8`/`i16`/`i32` (see docs for `ClosureKind`
/// for an explanation of that). The `GoalKind` is also the same type, but /// for an explanation of that). The `GoalKind` is also the same type, but
/// representing the kind of the trait that the closure is being called with. /// representing the kind of the trait that the closure is being called with.
#[cfg_attr(not(bootstrap), lang = "async_fn_kind_helper")] #[lang = "async_fn_kind_helper"]
trait AsyncFnKindHelper<GoalKind> { trait AsyncFnKindHelper<GoalKind> {
// Projects a set of closure inputs (arguments), a region, and a set of upvars // Projects a set of closure inputs (arguments), a region, and a set of upvars
// (by move and by ref) to the upvars that we expect the coroutine to have // (by move and by ref) to the upvars that we expect the coroutine to have

View File

@ -117,11 +117,7 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: boo
panic_fmt(fmt); panic_fmt(fmt);
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block super::intrinsics::const_eval_select((fmt, force_no_backtrace), comptime, runtime);
// SAFETY: const panic does not care about unwinding
unsafe {
super::intrinsics::const_eval_select((fmt, force_no_backtrace), comptime, runtime);
}
} }
// Next we define a bunch of higher-level wrappers that all bottom out in the two core functions // Next we define a bunch of higher-level wrappers that all bottom out in the two core functions

View File

@ -48,12 +48,8 @@ impl<T: ?Sized> *const T {
} }
} }
// on bootstrap bump, remove unsafe block #[allow(unused_unsafe)]
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] const_eval_select((self as *const u8,), const_impl, runtime_impl)
// SAFETY: The two versions are equivalent at runtime.
unsafe {
const_eval_select((self as *const u8,), const_impl, runtime_impl)
}
} }
/// Casts to a pointer of another type. /// Casts to a pointer of another type.
@ -818,13 +814,8 @@ impl<T: ?Sized> *const T {
true true
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] #[allow(unused_unsafe)]
// on bootstrap bump, remove unsafe block intrinsics::const_eval_select((this, origin), comptime, runtime)
// SAFETY: This function is only used to provide the same check that the const eval
// interpreter does at runtime.
unsafe {
intrinsics::const_eval_select((this, origin), comptime, runtime)
}
} }
assert_unsafe_precondition!( assert_unsafe_precondition!(
@ -1648,11 +1639,7 @@ impl<T: ?Sized> *const T {
// The cast to `()` is used to // The cast to `()` is used to
// 1. deal with fat pointers; and // 1. deal with fat pointers; and
// 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset. // 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset.
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((self.cast::<()>(), align), const_impl, runtime_impl)
// SAFETY: The two versions are equivalent at runtime.
unsafe {
const_eval_select((self.cast::<()>(), align), const_impl, runtime_impl)
}
} }
} }

View File

@ -48,11 +48,7 @@ impl<T: ?Sized> *mut T {
} }
} }
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((self as *mut u8,), const_impl, runtime_impl)
// SAFETY: The two versions are equivalent at runtime.
unsafe {
const_eval_select((self as *mut u8,), const_impl, runtime_impl)
}
} }
/// Casts to a pointer of another type. /// Casts to a pointer of another type.
@ -1906,11 +1902,7 @@ impl<T: ?Sized> *mut T {
// The cast to `()` is used to // The cast to `()` is used to
// 1. deal with fat pointers; and // 1. deal with fat pointers; and
// 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset. // 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset.
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((self.cast::<()>(), align), const_impl, runtime_impl)
// SAFETY: The two versions are equivalent at runtime.
unsafe {
const_eval_select((self.cast::<()>(), align), const_impl, runtime_impl)
}
} }
} }

View File

@ -35,15 +35,7 @@ where
#[track_caller] #[track_caller]
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
const fn slice_start_index_len_fail(index: usize, len: usize) -> ! { const fn slice_start_index_len_fail(index: usize, len: usize) -> ! {
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((index, len), slice_start_index_len_fail_ct, slice_start_index_len_fail_rt)
// SAFETY: we are just panicking here
unsafe {
const_eval_select(
(index, len),
slice_start_index_len_fail_ct,
slice_start_index_len_fail_rt,
)
}
} }
// FIXME const-hack // FIXME const-hack
@ -64,11 +56,7 @@ const fn slice_start_index_len_fail_ct(_: usize, _: usize) -> ! {
#[track_caller] #[track_caller]
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
const fn slice_end_index_len_fail(index: usize, len: usize) -> ! { const fn slice_end_index_len_fail(index: usize, len: usize) -> ! {
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((index, len), slice_end_index_len_fail_ct, slice_end_index_len_fail_rt)
// SAFETY: we are just panicking here
unsafe {
const_eval_select((index, len), slice_end_index_len_fail_ct, slice_end_index_len_fail_rt)
}
} }
// FIXME const-hack // FIXME const-hack
@ -89,11 +77,7 @@ const fn slice_end_index_len_fail_ct(_: usize, _: usize) -> ! {
#[track_caller] #[track_caller]
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
const fn slice_index_order_fail(index: usize, end: usize) -> ! { const fn slice_index_order_fail(index: usize, end: usize) -> ! {
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block const_eval_select((index, end), slice_index_order_fail_ct, slice_index_order_fail_rt)
// SAFETY: we are just panicking here
unsafe {
const_eval_select((index, end), slice_index_order_fail_ct, slice_index_order_fail_rt)
}
} }
// FIXME const-hack // FIXME const-hack

View File

@ -86,15 +86,7 @@ use iter::{MatchesInternal, SplitNInternal};
#[rustc_allow_const_fn_unstable(const_eval_select)] #[rustc_allow_const_fn_unstable(const_eval_select)]
#[cfg(not(feature = "panic_immediate_abort"))] #[cfg(not(feature = "panic_immediate_abort"))]
const fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! { const fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block crate::intrinsics::const_eval_select((s, begin, end), slice_error_fail_ct, slice_error_fail_rt)
// SAFETY: panics for both branches
unsafe {
crate::intrinsics::const_eval_select(
(s, begin, end),
slice_error_fail_ct,
slice_error_fail_rt,
)
}
} }
#[cfg(feature = "panic_immediate_abort")] #[cfg(feature = "panic_immediate_abort")]

View File

@ -49,7 +49,7 @@ fn test_iterator_step_by_nth() {
} }
#[test] #[test]
#[cfg_attr(not(bootstrap), allow(non_local_definitions))] #[allow(non_local_definitions)]
fn test_iterator_step_by_nth_overflow() { fn test_iterator_step_by_nth_overflow() {
#[cfg(target_pointer_width = "16")] #[cfg(target_pointer_width = "16")]
type Bigger = u32; type Bigger = u32;

View File

@ -195,7 +195,7 @@ pub fn test_unwrap_or_default() {
} }
#[test] #[test]
#[cfg_attr(not(bootstrap), allow(non_local_definitions))] #[allow(non_local_definitions)]
pub fn test_into_ok() { pub fn test_into_ok() {
fn infallible_op() -> Result<isize, !> { fn infallible_op() -> Result<isize, !> {
Ok(666) Ok(666)
@ -218,7 +218,7 @@ pub fn test_into_ok() {
} }
#[test] #[test]
#[cfg_attr(not(bootstrap), allow(non_local_definitions))] #[allow(non_local_definitions)]
pub fn test_into_err() { pub fn test_into_err() {
fn until_error_op() -> Result<!, isize> { fn until_error_op() -> Result<!, isize> {
Err(666) Err(666)

View File

@ -270,9 +270,6 @@
// //
// Language features: // Language features:
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(exhaustive_patterns))]
#![cfg_attr(bootstrap, feature(platform_intrinsics))]
#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))]
#![feature(alloc_error_handler)] #![feature(alloc_error_handler)]
#![feature(allocator_internals)] #![feature(allocator_internals)]
#![feature(allow_internal_unsafe)] #![feature(allow_internal_unsafe)]
@ -297,6 +294,7 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(link_cfg)] #![feature(link_cfg)]
#![feature(linkage)] #![feature(linkage)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(must_not_suspend)] #![feature(must_not_suspend)]
#![feature(needs_panic_runtime)] #![feature(needs_panic_runtime)]

View File

@ -12,8 +12,7 @@ pub macro thread_local_inner {
#[inline] // see comments below #[inline] // see comments below
#[deny(unsafe_op_in_unsafe_fn)] #[deny(unsafe_op_in_unsafe_fn)]
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint // FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[cfg_attr(bootstrap, allow(static_mut_ref))] #[allow(static_mut_refs)]
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
unsafe fn __getit( unsafe fn __getit(
_init: $crate::option::Option<&mut $crate::option::Option<$t>>, _init: $crate::option::Option<&mut $crate::option::Option<$t>>,
) -> $crate::option::Option<&'static $t> { ) -> $crate::option::Option<&'static $t> {

View File

@ -3,7 +3,6 @@
#![feature(link_cfg)] #![feature(link_cfg)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(c_unwind)] #![feature(c_unwind)]
#![cfg_attr(bootstrap, feature(cfg_target_abi))]
#![feature(strict_provenance)] #![feature(strict_provenance)]
#![cfg_attr(not(target_env = "msvc"), feature(libc))] #![cfg_attr(not(target_env = "msvc"), feature(libc))]
#![cfg_attr( #![cfg_attr(

View File

@ -537,15 +537,9 @@ fn wasm_special() {
("wasm32-wasi", "wasm32", true), ("wasm32-wasi", "wasm32", true),
("wasm32-wasi", "wasm32-bare", false), ("wasm32-wasi", "wasm32-bare", false),
("wasm32-wasi", "wasi", true), ("wasm32-wasi", "wasi", true),
// NB: the wasm32-wasip1 target is new so this isn't tested for
// the bootstrap compiler.
#[cfg(not(bootstrap))]
("wasm32-wasip1", "emscripten", false), ("wasm32-wasip1", "emscripten", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1", "wasm32", true), ("wasm32-wasip1", "wasm32", true),
#[cfg(not(bootstrap))]
("wasm32-wasip1", "wasm32-bare", false), ("wasm32-wasip1", "wasm32-bare", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1", "wasi", true), ("wasm32-wasip1", "wasi", true),
("wasm64-unknown-unknown", "emscripten", false), ("wasm64-unknown-unknown", "emscripten", false),
("wasm64-unknown-unknown", "wasm32", false), ("wasm64-unknown-unknown", "wasm32", false),
@ -604,11 +598,8 @@ fn threads_support() {
("aarch64-apple-darwin", true), ("aarch64-apple-darwin", true),
("wasm32-unknown-unknown", false), ("wasm32-unknown-unknown", false),
("wasm64-unknown-unknown", false), ("wasm64-unknown-unknown", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1", false), ("wasm32-wasip1", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1-threads", true), ("wasm32-wasip1-threads", true),
("wasm32-wasi-preview1-threads", true),
]; ];
for (target, has_threads) in threads { for (target, has_threads) in threads {
let config = cfg().target(target).build(); let config = cfg().target(target).build();

View File

@ -66,7 +66,7 @@ where
} }
} }
#[cfg_attr(not(bootstrap), allow(non_local_definitions))] #[allow(non_local_definitions)]
impl From<&FileName> for rustc_span::FileName { impl From<&FileName> for rustc_span::FileName {
fn from(filename: &FileName) -> rustc_span::FileName { fn from(filename: &FileName) -> rustc_span::FileName {
match filename { match filename {