Skip to content

Commit 5577a58

Browse files
step cfgs
1 parent e4c58eb commit 5577a58

File tree

35 files changed

+48
-133
lines changed

35 files changed

+48
-133
lines changed

compiler/rustc_ast/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(box_patterns)]
1717
#![feature(if_let_guard)]
1818
#![feature(let_chains)]
19-
#![cfg_attr(bootstrap, feature(min_specialization))]
2019
#![feature(never_type)]
2120
#![feature(negative_impls)]
2221
#![feature(stmt_expr_attributes)]

compiler/rustc_errors/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#![allow(internal_features)]
88
#![allow(rustc::diagnostic_outside_of_impl)]
99
#![allow(rustc::untranslatable_diagnostic)]
10-
#![cfg_attr(bootstrap, feature(min_specialization))]
1110
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1211
#![doc(rust_logo)]
1312
#![feature(array_windows)]

compiler/rustc_hir/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(associated_type_defaults)]
66
#![feature(closure_track_caller)]
77
#![feature(let_chains)]
8-
#![cfg_attr(bootstrap, feature(min_specialization))]
98
#![feature(never_type)]
109
#![feature(rustc_attrs)]
1110
#![feature(variant_count)]

compiler/rustc_hir_analysis/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ This API is completely unstable and subject to change.
6868
#![feature(is_sorted)]
6969
#![feature(iter_intersperse)]
7070
#![feature(let_chains)]
71-
#![cfg_attr(bootstrap, feature(min_specialization))]
7271
#![feature(never_type)]
7372
#![feature(lazy_cell)]
7473
#![feature(slice_partition_dedup)]

compiler/rustc_hir_typeck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(try_blocks)]
66
#![feature(never_type)]
77
#![feature(box_patterns)]
8-
#![cfg_attr(bootstrap, feature(min_specialization))]
98
#![feature(control_flow_enum)]
109

1110
#[macro_use]

compiler/rustc_infer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#![feature(let_chains)]
2626
#![feature(if_let_guard)]
2727
#![feature(iterator_try_collect)]
28-
#![cfg_attr(bootstrap, feature(min_specialization))]
2928
#![feature(try_blocks)]
3029
#![recursion_limit = "512"] // For rustdoc
3130

compiler/rustc_middle/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
2525
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2626
#![doc(rust_logo)]
27-
#![cfg_attr(bootstrap, feature(exhaustive_patterns))]
28-
#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))]
27+
#![feature(min_exhaustive_patterns)]
2928
#![feature(rustdoc_internals)]
3029
#![feature(allocator_api)]
3130
#![feature(array_windows)]

compiler/rustc_mir_build/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#![feature(box_patterns)]
1010
#![feature(if_let_guard)]
1111
#![feature(let_chains)]
12-
#![cfg_attr(bootstrap, feature(min_specialization))]
1312
#![feature(try_blocks)]
1413

1514
#[macro_use]

compiler/rustc_mir_dataflow/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(box_patterns)]
33
#![feature(exact_size_is_empty)]
44
#![feature(let_chains)]
5-
#![cfg_attr(bootstrap, feature(min_specialization))]
65
#![feature(try_blocks)]
76

87
#[macro_use]

compiler/rustc_mir_transform/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![feature(is_sorted)]
99
#![feature(let_chains)]
1010
#![feature(map_try_insert)]
11-
#![cfg_attr(bootstrap, feature(min_specialization))]
1211
#![feature(never_type)]
1312
#![feature(option_get_or_insert_default)]
1413
#![feature(round_char_boundary)]

compiler/rustc_target/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
1010
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1111
#![doc(rust_logo)]
12-
#![cfg_attr(bootstrap, feature(exhaustive_patterns))]
13-
#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))]
12+
#![feature(min_exhaustive_patterns)]
1413
#![feature(rustdoc_internals)]
1514
#![feature(assert_matches)]
1615
#![feature(iter_intersperse)]
1716
#![feature(let_chains)]
18-
#![cfg_attr(bootstrap, feature(min_specialization))]
1917
#![feature(rustc_attrs)]
2018
#![feature(step_trait)]
2119
#![allow(internal_features)]

compiler/rustc_trait_selection/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#![feature(option_take_if)]
2727
#![feature(never_type)]
2828
#![feature(type_alias_impl_trait)]
29-
#![cfg_attr(bootstrap, feature(min_specialization))]
3029
#![recursion_limit = "512"] // For rustdoc
3130

3231
#[macro_use]

library/alloc/src/alloc.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extern "Rust" {
5151
#[derive(Copy, Clone, Default, Debug)]
5252
#[cfg(not(test))]
5353
// the compiler needs to know when a Box uses the global allocator vs a custom one
54-
#[cfg_attr(not(bootstrap), lang = "global_alloc_ty")]
54+
#[lang = "global_alloc_ty"]
5555
pub struct Global;
5656

5757
#[cfg(test)]
@@ -387,8 +387,7 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
387387
}
388388

389389
#[cfg(not(feature = "panic_immediate_abort"))]
390-
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
391-
unsafe {
390+
{
392391
core::intrinsics::const_eval_select((layout,), ct_error, rt_error)
393392
}
394393

library/core/src/convert/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub trait AsMut<T: ?Sized> {
396396
/// For example, take this code:
397397
///
398398
/// ```
399-
/// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))]
399+
/// # #![allow(non_local_definitions)]
400400
/// struct Wrapper<T>(Vec<T>);
401401
/// impl<T> From<Wrapper<T>> for Vec<T> {
402402
/// fn from(w: Wrapper<T>) -> Vec<T> {

library/core/src/ffi/c_str.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,7 @@ impl CStr {
438438
unsafe { &*(bytes as *const [u8] as *const CStr) }
439439
}
440440

441-
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
442-
// SAFETY: The const and runtime versions have identical behavior
443-
// unless the safety contract of `from_bytes_with_nul_unchecked` is
444-
// violated, which is UB.
445-
unsafe {
446-
intrinsics::const_eval_select((bytes,), const_impl, rt_impl)
447-
}
441+
intrinsics::const_eval_select((bytes,), const_impl, rt_impl)
448442
}
449443

450444
/// Returns the inner pointer to this C string.
@@ -759,7 +753,7 @@ const unsafe fn const_strlen(ptr: *const c_char) -> usize {
759753
unsafe { strlen(s) }
760754
}
761755

762-
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
756+
#[allow(unused_unsafe)] // on bootstrap bump, remove unsafe block
763757
// SAFETY: the two functions always provide equivalent functionality
764758
unsafe {
765759
intrinsics::const_eval_select((ptr,), strlen_ct, strlen_rt)

library/core/src/hash/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ pub trait Hasher {
454454
/// ```
455455
/// #![feature(hasher_prefixfree_extras)]
456456
/// # // Stubs to make the `impl` below pass the compiler
457-
/// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))]
457+
/// # #![allow(non_local_definitions)]
458458
/// # struct MyCollection<T>(Option<T>);
459459
/// # impl<T> MyCollection<T> {
460460
/// # fn len(&self) -> usize { todo!() }

library/core/src/intrinsics.rs

+14-53
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
8484
unsafe { crate::ptr::drop_in_place(to_drop) }
8585
}
8686

87-
#[cfg(bootstrap)]
88-
pub use self::r#try as catch_unwind;
89-
9087
extern "rust-intrinsic" {
9188
// N.B., these intrinsics take raw pointers because they mutate aliased
9289
// memory, which is not valid for either `&` or `&mut`.
@@ -965,8 +962,7 @@ extern "rust-intrinsic" {
965962
#[rustc_const_stable(feature = "const_assume", since = "1.77.0")]
966963
#[rustc_nounwind]
967964
#[unstable(feature = "core_intrinsics", issue = "none")]
968-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
969-
#[cfg_attr(bootstrap, inline)]
965+
#[rustc_intrinsic]
970966
pub const unsafe fn assume(b: bool) {
971967
if !b {
972968
// SAFETY: the caller must guarantee the argument is never `false`
@@ -987,9 +983,8 @@ pub const unsafe fn assume(b: bool) {
987983
/// This intrinsic does not have a stable counterpart.
988984
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
989985
#[unstable(feature = "core_intrinsics", issue = "none")]
990-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
986+
#[rustc_intrinsic]
991987
#[rustc_nounwind]
992-
#[cfg_attr(bootstrap, inline)]
993988
pub const fn likely(b: bool) -> bool {
994989
b
995990
}
@@ -1007,9 +1002,8 @@ pub const fn likely(b: bool) -> bool {
10071002
/// This intrinsic does not have a stable counterpart.
10081003
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
10091004
#[unstable(feature = "core_intrinsics", issue = "none")]
1010-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
1005+
#[rustc_intrinsic]
10111006
#[rustc_nounwind]
1012-
#[cfg_attr(bootstrap, inline)]
10131007
pub const fn unlikely(b: bool) -> bool {
10141008
b
10151009
}
@@ -1919,39 +1913,34 @@ extern "rust-intrinsic" {
19191913
/// This intrinsic does not have a stable counterpart.
19201914
#[rustc_nounwind]
19211915
#[rustc_safe_intrinsic]
1922-
#[cfg(not(bootstrap))]
19231916
pub fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
19241917

19251918
/// Float subtraction that allows optimizations based on algebraic rules.
19261919
///
19271920
/// This intrinsic does not have a stable counterpart.
19281921
#[rustc_nounwind]
19291922
#[rustc_safe_intrinsic]
1930-
#[cfg(not(bootstrap))]
19311923
pub fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
19321924

19331925
/// Float multiplication that allows optimizations based on algebraic rules.
19341926
///
19351927
/// This intrinsic does not have a stable counterpart.
19361928
#[rustc_nounwind]
19371929
#[rustc_safe_intrinsic]
1938-
#[cfg(not(bootstrap))]
19391930
pub fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
19401931

19411932
/// Float division that allows optimizations based on algebraic rules.
19421933
///
19431934
/// This intrinsic does not have a stable counterpart.
19441935
#[rustc_nounwind]
19451936
#[rustc_safe_intrinsic]
1946-
#[cfg(not(bootstrap))]
19471937
pub fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
19481938

19491939
/// Float remainder that allows optimizations based on algebraic rules.
19501940
///
19511941
/// This intrinsic does not have a stable counterpart.
19521942
#[rustc_nounwind]
19531943
#[rustc_safe_intrinsic]
1954-
#[cfg(not(bootstrap))]
19551944
pub fn frem_algebraic<T: Copy>(a: T, b: T) -> T;
19561945

19571946
/// Convert with LLVM’s fptoui/fptosi, which may return undef for values out of range
@@ -2407,14 +2396,8 @@ extern "rust-intrinsic" {
24072396
///
24082397
/// The stable version of this intrinsic is `std::panic::catch_unwind`.
24092398
#[rustc_nounwind]
2410-
#[cfg(not(bootstrap))]
24112399
pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
24122400

2413-
/// For bootstrap only, see `catch_unwind`.
2414-
#[rustc_nounwind]
2415-
#[cfg(bootstrap)]
2416-
pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
2417-
24182401
/// Emits a `!nontemporal` store according to LLVM (see their docs).
24192402
/// Probably will never become stable.
24202403
///
@@ -2518,9 +2501,9 @@ extern "rust-intrinsic" {
25182501
#[cfg(bootstrap)]
25192502
pub fn vtable_align(ptr: *const ()) -> usize;
25202503

2521-
#[cfg(bootstrap)]
25222504
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
2523-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
2505+
#[rustc_safe_intrinsic]
2506+
#[cfg(bootstrap)]
25242507
pub fn const_eval_select<ARG: Tuple, F, G, RET>(
25252508
arg: ARG,
25262509
called_in_const: F,
@@ -2650,8 +2633,7 @@ where
26502633
#[rustc_const_unstable(feature = "is_val_statically_known", issue = "none")]
26512634
#[rustc_nounwind]
26522635
#[unstable(feature = "core_intrinsics", issue = "none")]
2653-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2654-
#[cfg_attr(bootstrap, inline)]
2636+
#[rustc_intrinsic]
26552637
pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
26562638
false
26572639
}
@@ -2670,7 +2652,7 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
26702652
#[rustc_const_unstable(feature = "ub_checks", issue = "none")]
26712653
#[unstable(feature = "core_intrinsics", issue = "none")]
26722654
#[inline(always)]
2673-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2655+
#[rustc_intrinsic]
26742656
pub(crate) const fn check_library_ub() -> bool {
26752657
cfg!(debug_assertions)
26762658
}
@@ -2686,7 +2668,7 @@ pub(crate) const fn check_library_ub() -> bool {
26862668
#[rustc_const_unstable(feature = "ub_checks", issue = "none")]
26872669
#[unstable(feature = "core_intrinsics", issue = "none")]
26882670
#[inline(always)]
2689-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2671+
#[rustc_intrinsic]
26902672
pub(crate) const fn check_language_ub() -> bool {
26912673
cfg!(debug_assertions)
26922674
}
@@ -2702,8 +2684,7 @@ pub(crate) const fn check_language_ub() -> bool {
27022684
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
27032685
#[unstable(feature = "core_intrinsics", issue = "none")]
27042686
#[rustc_nounwind]
2705-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2706-
#[cfg_attr(bootstrap, inline)]
2687+
#[rustc_intrinsic]
27072688
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
27082689
// const eval overrides this function, but runtime code should always just return null pointers.
27092690
crate::ptr::null_mut()
@@ -2722,8 +2703,7 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
27222703
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
27232704
#[unstable(feature = "core_intrinsics", issue = "none")]
27242705
#[rustc_nounwind]
2725-
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2726-
#[cfg_attr(bootstrap, inline)]
2706+
#[rustc_intrinsic]
27272707
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
27282708

27292709
/// `ptr` must point to a vtable.
@@ -2799,15 +2779,6 @@ pub unsafe fn vtable_align(_ptr: *const ()) -> usize {
27992779
macro_rules! assert_unsafe_precondition {
28002780
($kind:ident, $message:expr, ($($name:ident:$ty:ty = $arg:expr),*$(,)?) => $e:expr $(,)?) => {
28012781
{
2802-
// #[cfg(bootstrap)] (this comment)
2803-
// When the standard library is compiled with debug assertions, we want the check to inline for better performance.
2804-
// This is important when working on the compiler, which is compiled with debug assertions locally.
2805-
// When not compiled with debug assertions (so the precompiled std) we outline the check to minimize the compile
2806-
// time impact when debug assertions are disabled.
2807-
// The proper solution to this is the `#[rustc_no_mir_inline]` below, but we still want decent performance for cfg(bootstrap).
2808-
#[cfg_attr(all(debug_assertions, bootstrap), inline(always))]
2809-
#[cfg_attr(all(not(debug_assertions), bootstrap), inline(never))]
2810-
28112782
// This check is inlineable, but not by the MIR inliner.
28122783
// The reason for this is that the MIR inliner is in an exceptionally bad position
28132784
// 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 {
28162787
//
28172788
// LLVM on the other hand sees the constant branch, so if it's `false`, it can immediately delete it without
28182789
// inlining the check. If it's `true`, it can inline it and get significantly better performance.
2819-
#[cfg_attr(not(bootstrap), rustc_no_mir_inline)]
2820-
#[cfg_attr(not(bootstrap), inline)]
2790+
#[rustc_no_mir_inline]
2791+
#[inline]
28212792
#[rustc_nounwind]
28222793
#[rustc_const_unstable(feature = "ub_checks", issue = "none")]
28232794
const fn precondition_check($($name:$ty),*) {
@@ -2885,13 +2856,7 @@ pub(crate) const fn is_nonoverlapping(
28852856
true
28862857
}
28872858

2888-
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
2889-
// SAFETY: This function's precondition is equivalent to that of `const_eval_select`.
2890-
// Programs which do not execute UB will only see this function return `true`, which makes the
2891-
// const and runtime implementation indistinguishable.
2892-
unsafe {
2893-
const_eval_select((src, dst, size, count), comptime, runtime)
2894-
}
2859+
const_eval_select((src, dst, size, count), comptime, runtime)
28952860
}
28962861

28972862
/// 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
32083173

32093174
const fn compiletime(_ptr: *const (), _align: usize) {}
32103175

3211-
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
3212-
// SAFETY: the extra behavior at runtime is for UB checks only.
3213-
unsafe {
3214-
const_eval_select((ptr, align), compiletime, runtime);
3215-
}
3176+
const_eval_select((ptr, align), compiletime, runtime);
32163177
}

library/core/src/intrinsics/simd.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
//!
33
//! In this module, a "vector" is any `repr(simd)` type.
44
5-
// Temporary macro while we switch the ABI from "platform-intrinsics" to "intrinsics".
6-
#[rustfmt::skip]
7-
macro_rules! declare_intrinsics {
8-
($abi:tt) => {
9-
extern $abi {
5+
extern "rust-intrinsic" {
106
/// Insert an element into a vector, returning the updated vector.
117
///
128
/// `T` must be a vector with element type `U`.
@@ -659,10 +655,3 @@ extern $abi {
659655
#[rustc_nounwind]
660656
pub fn simd_flog<T>(a: T) -> T;
661657
}
662-
}
663-
}
664-
665-
#[cfg(bootstrap)]
666-
declare_intrinsics!("platform-intrinsic");
667-
#[cfg(not(bootstrap))]
668-
declare_intrinsics!("rust-intrinsic");

0 commit comments

Comments
 (0)