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(if_let_guard)]
#![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(never_type)]
#![feature(negative_impls)]
#![feature(stmt_expr_attributes)]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -51,7 +51,7 @@ extern "Rust" {
#[derive(Copy, Clone, Default, Debug)]
#[cfg(not(test))]
// 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;
#[cfg(test)]
@ -387,8 +387,7 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
}
#[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)
}

View File

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

View File

@ -438,14 +438,8 @@ impl CStr {
unsafe { &*(bytes as *const [u8] as *const CStr) }
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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.
///
@ -759,12 +753,8 @@ const unsafe fn const_strlen(ptr: *const c_char) -> usize {
unsafe { strlen(s) }
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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.
///

View File

@ -454,7 +454,7 @@ pub trait Hasher {
/// ```
/// #![feature(hasher_prefixfree_extras)]
/// # // 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>);
/// # impl<T> MyCollection<T> {
/// # 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) }
}
#[cfg(bootstrap)]
pub use self::r#try as catch_unwind;
extern "rust-intrinsic" {
// N.B., these intrinsics take raw pointers because they mutate aliased
// 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_nounwind]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[cfg_attr(bootstrap, inline)]
#[rustc_intrinsic]
pub const unsafe fn assume(b: bool) {
if !b {
// 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.
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg_attr(bootstrap, inline)]
pub const fn likely(b: bool) -> bool {
b
}
@ -1007,9 +1002,8 @@ pub const fn likely(b: bool) -> bool {
/// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg_attr(bootstrap, inline)]
pub const fn unlikely(b: bool) -> bool {
b
}
@ -1919,7 +1913,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
#[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float subtraction that allows optimizations based on algebraic rules.
@ -1927,7 +1920,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
#[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float multiplication that allows optimizations based on algebraic rules.
@ -1935,7 +1927,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
#[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float division that allows optimizations based on algebraic rules.
@ -1943,7 +1934,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
#[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
pub fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
/// Float remainder that allows optimizations based on algebraic rules.
@ -1951,7 +1941,6 @@ extern "rust-intrinsic" {
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
#[rustc_safe_intrinsic]
#[cfg(not(bootstrap))]
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
@ -2407,14 +2396,8 @@ extern "rust-intrinsic" {
///
/// The stable version of this intrinsic is `std::panic::catch_unwind`.
#[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;
/// 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).
/// Probably will never become stable.
///
@ -2518,9 +2501,9 @@ extern "rust-intrinsic" {
#[cfg(bootstrap)]
pub fn vtable_align(ptr: *const ()) -> usize;
#[cfg(bootstrap)]
#[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>(
arg: ARG,
called_in_const: F,
@ -2650,8 +2633,7 @@ where
#[rustc_const_unstable(feature = "is_val_statically_known", issue = "none")]
#[rustc_nounwind]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[cfg_attr(bootstrap, inline)]
#[rustc_intrinsic]
pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
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")]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[inline(always)]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub(crate) const fn check_library_ub() -> bool {
cfg!(debug_assertions)
}
@ -2686,7 +2668,7 @@ pub(crate) const fn check_library_ub() -> bool {
#[rustc_const_unstable(feature = "ub_checks", issue = "none")]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[inline(always)]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[rustc_intrinsic]
pub(crate) const fn check_language_ub() -> bool {
cfg!(debug_assertions)
}
@ -2702,8 +2684,7 @@ pub(crate) const fn check_language_ub() -> bool {
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[cfg_attr(bootstrap, inline)]
#[rustc_intrinsic]
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.
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")]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
#[cfg_attr(bootstrap, inline)]
#[rustc_intrinsic]
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
/// `ptr` must point to a vtable.
@ -2799,15 +2779,6 @@ pub unsafe fn vtable_align(_ptr: *const ()) -> usize {
macro_rules! assert_unsafe_precondition {
($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.
// 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`,
@ -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
// inlining the check. If it's `true`, it can inline it and get significantly better performance.
#[cfg_attr(not(bootstrap), rustc_no_mir_inline)]
#[cfg_attr(not(bootstrap), inline)]
#[rustc_no_mir_inline]
#[inline]
#[rustc_nounwind]
#[rustc_const_unstable(feature = "ub_checks", issue = "none")]
const fn precondition_check($($name:$ty),*) {
@ -2885,14 +2856,8 @@ pub(crate) const fn is_nonoverlapping(
true
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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
/// and destination must *not* overlap.
@ -3208,9 +3173,5 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize
const fn compiletime(_ptr: *const (), _align: usize) {}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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.
// Temporary macro while we switch the ABI from "platform-intrinsics" to "intrinsics".
#[rustfmt::skip]
macro_rules! declare_intrinsics {
($abi:tt) => {
extern $abi {
extern "rust-intrinsic" {
/// Insert an element into a vector, returning the updated vector.
///
/// `T` must be a vector with element type `U`.
@ -659,10 +655,3 @@ extern $abi {
#[rustc_nounwind]
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:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(associated_type_bounds))]
#![feature(array_ptr_get)]
#![feature(char_indices_offset)]
#![feature(const_align_of_val)]
@ -203,12 +204,6 @@
//
// Language features:
// 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(adt_const_params)]
#![feature(allow_internal_unsafe)]
@ -233,6 +228,7 @@
#![feature(doc_notable_trait)]
#![feature(effects)]
#![feature(extern_types)]
#![feature(freeze_impls)]
#![feature(fundamental)]
#![feature(generic_arg_infer)]
#![feature(if_let_guard)]
@ -243,6 +239,7 @@
#![feature(let_chains)]
#![feature(link_llvm_intrinsics)]
#![feature(macro_metavar_expr)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)]
#![feature(multiple_supertrait_upcastable)]
#![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`,
/// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied.
#[unstable(feature = "transmutability", issue = "99571")]
#[cfg_attr(not(bootstrap), lang = "transmute_trait")]
#[lang = "transmute_trait"]
#[rustc_deny_explicit_impl(implement_via_object = false)]
#[rustc_coinductive]
pub unsafe trait BikeshedIntrinsicFrom<Src, const ASSUME: Assume = { Assume::NOTHING }>

View File

@ -1153,12 +1153,8 @@ impl f32 {
// Stability concerns.
unsafe { mem::transmute(x) }
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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`.
///
@ -1248,12 +1244,8 @@ impl f32 {
// Stability concerns.
unsafe { mem::transmute(x) }
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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
/// big-endian (network) byte order.

View File

@ -1146,12 +1146,8 @@ impl f64 {
// Stability concerns.
unsafe { mem::transmute::<f64, u64>(rt) }
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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`.
///
@ -1246,12 +1242,8 @@ impl f64 {
// Stability concerns.
unsafe { mem::transmute::<u64, f64>(rt) }
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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
/// big-endian (network) byte order.

View File

@ -140,7 +140,7 @@ mod internal_implementation_detail {
/// 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
/// 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> {
// 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

View File

@ -117,12 +117,8 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: boo
panic_fmt(fmt);
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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
// above.

View File

@ -48,13 +48,9 @@ impl<T: ?Sized> *const T {
}
}
// on bootstrap bump, remove unsafe block
#[cfg_attr(not(bootstrap), allow(unused_unsafe))]
// SAFETY: The two versions are equivalent at runtime.
unsafe {
#[allow(unused_unsafe)]
const_eval_select((self as *const u8,), const_impl, runtime_impl)
}
}
/// Casts to a pointer of another type.
#[stable(feature = "ptr_cast", since = "1.38.0")]
@ -818,14 +814,9 @@ impl<T: ?Sized> *const T {
true
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))]
// on bootstrap bump, remove unsafe block
// SAFETY: This function is only used to provide the same check that the const eval
// interpreter does at runtime.
unsafe {
#[allow(unused_unsafe)]
intrinsics::const_eval_select((this, origin), comptime, runtime)
}
}
assert_unsafe_precondition!(
check_language_ub,
@ -1648,13 +1639,9 @@ impl<T: ?Sized> *const T {
// The cast to `()` is used to
// 1. deal with fat pointers; and
// 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
// SAFETY: The two versions are equivalent at runtime.
unsafe {
const_eval_select((self.cast::<()>(), align), const_impl, runtime_impl)
}
}
}
impl<T> *const [T] {
/// Returns the length of a raw slice.

View File

@ -48,12 +48,8 @@ impl<T: ?Sized> *mut T {
}
}
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
// 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.
#[stable(feature = "ptr_cast", since = "1.38.0")]
@ -1906,13 +1902,9 @@ impl<T: ?Sized> *mut T {
// The cast to `()` is used to
// 1. deal with fat pointers; and
// 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
// SAFETY: The two versions are equivalent at runtime.
unsafe {
const_eval_select((self.cast::<()>(), align), const_impl, runtime_impl)
}
}
}
impl<T> *mut [T] {
/// Returns the length of a raw slice.

View File

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

View File

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

View File

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

View File

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

View File

@ -270,9 +270,6 @@
//
// Language features:
// 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(allocator_internals)]
#![feature(allow_internal_unsafe)]
@ -297,6 +294,7 @@
#![feature(let_chains)]
#![feature(link_cfg)]
#![feature(linkage)]
#![feature(min_exhaustive_patterns)]
#![feature(min_specialization)]
#![feature(must_not_suspend)]
#![feature(needs_panic_runtime)]

View File

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

View File

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

View File

@ -537,15 +537,9 @@ fn wasm_special() {
("wasm32-wasi", "wasm32", true),
("wasm32-wasi", "wasm32-bare", false),
("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),
#[cfg(not(bootstrap))]
("wasm32-wasip1", "wasm32", true),
#[cfg(not(bootstrap))]
("wasm32-wasip1", "wasm32-bare", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1", "wasi", true),
("wasm64-unknown-unknown", "emscripten", false),
("wasm64-unknown-unknown", "wasm32", false),
@ -604,11 +598,8 @@ fn threads_support() {
("aarch64-apple-darwin", true),
("wasm32-unknown-unknown", false),
("wasm64-unknown-unknown", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1", false),
#[cfg(not(bootstrap))]
("wasm32-wasip1-threads", true),
("wasm32-wasi-preview1-threads", true),
];
for (target, has_threads) in threads {
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 {
fn from(filename: &FileName) -> rustc_span::FileName {
match filename {