Skip to content

Commit 6215778

Browse files
cfg-step code
1 parent 432627f commit 6215778

File tree

8 files changed

+49
-56
lines changed

8 files changed

+49
-56
lines changed

alloc/src/alloc.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,16 @@ extern "Rust" {
2828
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
2929
// like `malloc`, `realloc`, and `free`, respectively.
3030
#[rustc_allocator]
31-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
32-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
31+
#[rustc_nounwind]
3332
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
3433
#[rustc_deallocator]
35-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
36-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
34+
#[rustc_nounwind]
3735
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
3836
#[rustc_reallocator]
39-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
40-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
37+
#[rustc_nounwind]
4138
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
4239
#[rustc_allocator_zeroed]
43-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
44-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
40+
#[rustc_nounwind]
4541
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
4642
}
4743

core/src/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
/// ```
100100
#[cfg_attr(not(test), rustc_diagnostic_item = "Default")]
101101
#[stable(feature = "rust1", since = "1.0.0")]
102-
#[cfg_attr(not(bootstrap), const_trait)]
102+
#[const_trait]
103103
pub trait Default: Sized {
104104
/// Returns the "default value" for a type.
105105
///

core/src/intrinsics.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ extern "rust-intrinsic" {
790790
/// uninitialized at that point in the control flow.
791791
///
792792
/// This intrinsic should not be used outside of the compiler.
793-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
793+
#[rustc_safe_intrinsic]
794794
pub fn rustc_peek<T>(_: T) -> T;
795795

796796
/// Aborts the execution of the process.
@@ -808,7 +808,7 @@ extern "rust-intrinsic" {
808808
/// On Unix, the
809809
/// process will probably terminate with a signal like `SIGABRT`, `SIGILL`, `SIGTRAP`, `SIGSEGV` or
810810
/// `SIGBUS`. The precise behaviour is not guaranteed and not stable.
811-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
811+
#[rustc_safe_intrinsic]
812812
pub fn abort() -> !;
813813

814814
/// Informs the optimizer that this point in the code is not reachable,
@@ -847,7 +847,7 @@ extern "rust-intrinsic" {
847847
///
848848
/// This intrinsic does not have a stable counterpart.
849849
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
850-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
850+
#[rustc_safe_intrinsic]
851851
pub fn likely(b: bool) -> bool;
852852

853853
/// Hints to the compiler that branch condition is likely to be false.
@@ -862,7 +862,7 @@ extern "rust-intrinsic" {
862862
///
863863
/// This intrinsic does not have a stable counterpart.
864864
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
865-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
865+
#[rustc_safe_intrinsic]
866866
pub fn unlikely(b: bool) -> bool;
867867

868868
/// Executes a breakpoint trap, for inspection by a debugger.
@@ -882,7 +882,7 @@ extern "rust-intrinsic" {
882882
///
883883
/// The stabilized version of this intrinsic is [`core::mem::size_of`].
884884
#[rustc_const_stable(feature = "const_size_of", since = "1.40.0")]
885-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
885+
#[rustc_safe_intrinsic]
886886
pub fn size_of<T>() -> usize;
887887

888888
/// The minimum alignment of a type.
@@ -894,7 +894,7 @@ extern "rust-intrinsic" {
894894
///
895895
/// The stabilized version of this intrinsic is [`core::mem::align_of`].
896896
#[rustc_const_stable(feature = "const_min_align_of", since = "1.40.0")]
897-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
897+
#[rustc_safe_intrinsic]
898898
pub fn min_align_of<T>() -> usize;
899899
/// The preferred alignment of a type.
900900
///
@@ -923,7 +923,7 @@ extern "rust-intrinsic" {
923923
///
924924
/// The stabilized version of this intrinsic is [`core::any::type_name`].
925925
#[rustc_const_unstable(feature = "const_type_name", issue = "63084")]
926-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
926+
#[rustc_safe_intrinsic]
927927
pub fn type_name<T: ?Sized>() -> &'static str;
928928

929929
/// Gets an identifier which is globally unique to the specified type. This
@@ -937,31 +937,31 @@ extern "rust-intrinsic" {
937937
///
938938
/// The stabilized version of this intrinsic is [`core::any::TypeId::of`].
939939
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
940-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
940+
#[rustc_safe_intrinsic]
941941
pub fn type_id<T: ?Sized + 'static>() -> u64;
942942

943943
/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
944944
/// This will statically either panic, or do nothing.
945945
///
946946
/// This intrinsic does not have a stable counterpart.
947947
#[rustc_const_stable(feature = "const_assert_type", since = "1.59.0")]
948-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
948+
#[rustc_safe_intrinsic]
949949
pub fn assert_inhabited<T>();
950950

951951
/// A guard for unsafe functions that cannot ever be executed if `T` does not permit
952952
/// zero-initialization: This will statically either panic, or do nothing.
953953
///
954954
/// This intrinsic does not have a stable counterpart.
955955
#[rustc_const_unstable(feature = "const_assert_type2", issue = "none")]
956-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
956+
#[rustc_safe_intrinsic]
957957
pub fn assert_zero_valid<T>();
958958

959959
/// A guard for unsafe functions that cannot ever be executed if `T` has invalid
960960
/// bit patterns: This will statically either panic, or do nothing.
961961
///
962962
/// This intrinsic does not have a stable counterpart.
963963
#[rustc_const_unstable(feature = "const_assert_type2", issue = "none")]
964-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
964+
#[rustc_safe_intrinsic]
965965
pub fn assert_uninit_valid<T>();
966966

967967
/// Gets a reference to a static `Location` indicating where it was called.
@@ -973,7 +973,7 @@ extern "rust-intrinsic" {
973973
///
974974
/// Consider using [`core::panic::Location::caller`] instead.
975975
#[rustc_const_unstable(feature = "const_caller_location", issue = "76156")]
976-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
976+
#[rustc_safe_intrinsic]
977977
pub fn caller_location() -> &'static crate::panic::Location<'static>;
978978

979979
/// Moves a value out of scope without running drop glue.
@@ -986,7 +986,7 @@ extern "rust-intrinsic" {
986986
/// Therefore, implementations must not require the user to uphold
987987
/// any safety invariants.
988988
#[rustc_const_unstable(feature = "const_intrinsic_forget", issue = "none")]
989-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
989+
#[rustc_safe_intrinsic]
990990
pub fn forget<T: ?Sized>(_: T);
991991

992992
/// Reinterprets the bits of a value of one type as another type.
@@ -1266,7 +1266,7 @@ extern "rust-intrinsic" {
12661266
///
12671267
/// The stabilized version of this intrinsic is [`mem::needs_drop`](crate::mem::needs_drop).
12681268
#[rustc_const_stable(feature = "const_needs_drop", since = "1.40.0")]
1269-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1269+
#[rustc_safe_intrinsic]
12701270
pub fn needs_drop<T: ?Sized>() -> bool;
12711271

12721272
/// Calculates the offset from a pointer.
@@ -1311,7 +1311,7 @@ extern "rust-intrinsic" {
13111311
/// any safety invariants.
13121312
///
13131313
/// Consider using [`pointer::mask`] instead.
1314-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1314+
#[rustc_safe_intrinsic]
13151315
pub fn ptr_mask<T>(ptr: *const T, mask: usize) -> *const T;
13161316

13171317
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
@@ -1503,7 +1503,7 @@ extern "rust-intrinsic" {
15031503
///
15041504
/// The stabilized version of this intrinsic is
15051505
/// [`f32::min`]
1506-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1506+
#[rustc_safe_intrinsic]
15071507
pub fn minnumf32(x: f32, y: f32) -> f32;
15081508
/// Returns the minimum of two `f64` values.
15091509
///
@@ -1514,7 +1514,7 @@ extern "rust-intrinsic" {
15141514
///
15151515
/// The stabilized version of this intrinsic is
15161516
/// [`f64::min`]
1517-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1517+
#[rustc_safe_intrinsic]
15181518
pub fn minnumf64(x: f64, y: f64) -> f64;
15191519
/// Returns the maximum of two `f32` values.
15201520
///
@@ -1525,7 +1525,7 @@ extern "rust-intrinsic" {
15251525
///
15261526
/// The stabilized version of this intrinsic is
15271527
/// [`f32::max`]
1528-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1528+
#[rustc_safe_intrinsic]
15291529
pub fn maxnumf32(x: f32, y: f32) -> f32;
15301530
/// Returns the maximum of two `f64` values.
15311531
///
@@ -1536,7 +1536,7 @@ extern "rust-intrinsic" {
15361536
///
15371537
/// The stabilized version of this intrinsic is
15381538
/// [`f64::max`]
1539-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1539+
#[rustc_safe_intrinsic]
15401540
pub fn maxnumf64(x: f64, y: f64) -> f64;
15411541

15421542
/// Copies the sign from `y` to `x` for `f32` values.
@@ -1657,7 +1657,7 @@ extern "rust-intrinsic" {
16571657
/// primitives via the `count_ones` method. For example,
16581658
/// [`u32::count_ones`]
16591659
#[rustc_const_stable(feature = "const_ctpop", since = "1.40.0")]
1660-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1660+
#[rustc_safe_intrinsic]
16611661
pub fn ctpop<T: Copy>(x: T) -> T;
16621662

16631663
/// Returns the number of leading unset bits (zeroes) in an integer type `T`.
@@ -1695,7 +1695,7 @@ extern "rust-intrinsic" {
16951695
/// assert_eq!(num_leading, 16);
16961696
/// ```
16971697
#[rustc_const_stable(feature = "const_ctlz", since = "1.40.0")]
1698-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1698+
#[rustc_safe_intrinsic]
16991699
pub fn ctlz<T: Copy>(x: T) -> T;
17001700

17011701
/// Like `ctlz`, but extra-unsafe as it returns `undef` when
@@ -1752,7 +1752,7 @@ extern "rust-intrinsic" {
17521752
/// assert_eq!(num_trailing, 16);
17531753
/// ```
17541754
#[rustc_const_stable(feature = "const_cttz", since = "1.40.0")]
1755-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1755+
#[rustc_safe_intrinsic]
17561756
pub fn cttz<T: Copy>(x: T) -> T;
17571757

17581758
/// Like `cttz`, but extra-unsafe as it returns `undef` when
@@ -1785,7 +1785,7 @@ extern "rust-intrinsic" {
17851785
/// primitives via the `swap_bytes` method. For example,
17861786
/// [`u32::swap_bytes`]
17871787
#[rustc_const_stable(feature = "const_bswap", since = "1.40.0")]
1788-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1788+
#[rustc_safe_intrinsic]
17891789
pub fn bswap<T: Copy>(x: T) -> T;
17901790

17911791
/// Reverses the bits in an integer type `T`.
@@ -1799,7 +1799,7 @@ extern "rust-intrinsic" {
17991799
/// primitives via the `reverse_bits` method. For example,
18001800
/// [`u32::reverse_bits`]
18011801
#[rustc_const_stable(feature = "const_bitreverse", since = "1.40.0")]
1802-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1802+
#[rustc_safe_intrinsic]
18031803
pub fn bitreverse<T: Copy>(x: T) -> T;
18041804

18051805
/// Performs checked integer addition.
@@ -1813,7 +1813,7 @@ extern "rust-intrinsic" {
18131813
/// primitives via the `overflowing_add` method. For example,
18141814
/// [`u32::overflowing_add`]
18151815
#[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")]
1816-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1816+
#[rustc_safe_intrinsic]
18171817
pub fn add_with_overflow<T: Copy>(x: T, y: T) -> (T, bool);
18181818

18191819
/// Performs checked integer subtraction
@@ -1827,7 +1827,7 @@ extern "rust-intrinsic" {
18271827
/// primitives via the `overflowing_sub` method. For example,
18281828
/// [`u32::overflowing_sub`]
18291829
#[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")]
1830-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1830+
#[rustc_safe_intrinsic]
18311831
pub fn sub_with_overflow<T: Copy>(x: T, y: T) -> (T, bool);
18321832

18331833
/// Performs checked integer multiplication
@@ -1841,7 +1841,7 @@ extern "rust-intrinsic" {
18411841
/// primitives via the `overflowing_mul` method. For example,
18421842
/// [`u32::overflowing_mul`]
18431843
#[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")]
1844-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1844+
#[rustc_safe_intrinsic]
18451845
pub fn mul_with_overflow<T: Copy>(x: T, y: T) -> (T, bool);
18461846

18471847
/// Performs an exact division, resulting in undefined behavior where
@@ -1916,7 +1916,7 @@ extern "rust-intrinsic" {
19161916
/// primitives via the `rotate_left` method. For example,
19171917
/// [`u32::rotate_left`]
19181918
#[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
1919-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1919+
#[rustc_safe_intrinsic]
19201920
pub fn rotate_left<T: Copy>(x: T, y: T) -> T;
19211921

19221922
/// Performs rotate right.
@@ -1930,7 +1930,7 @@ extern "rust-intrinsic" {
19301930
/// primitives via the `rotate_right` method. For example,
19311931
/// [`u32::rotate_right`]
19321932
#[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
1933-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1933+
#[rustc_safe_intrinsic]
19341934
pub fn rotate_right<T: Copy>(x: T, y: T) -> T;
19351935

19361936
/// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
@@ -1944,7 +1944,7 @@ extern "rust-intrinsic" {
19441944
/// primitives via the `wrapping_add` method. For example,
19451945
/// [`u32::wrapping_add`]
19461946
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
1947-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1947+
#[rustc_safe_intrinsic]
19481948
pub fn wrapping_add<T: Copy>(a: T, b: T) -> T;
19491949
/// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
19501950
///
@@ -1957,7 +1957,7 @@ extern "rust-intrinsic" {
19571957
/// primitives via the `wrapping_sub` method. For example,
19581958
/// [`u32::wrapping_sub`]
19591959
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
1960-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1960+
#[rustc_safe_intrinsic]
19611961
pub fn wrapping_sub<T: Copy>(a: T, b: T) -> T;
19621962
/// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
19631963
///
@@ -1970,7 +1970,7 @@ extern "rust-intrinsic" {
19701970
/// primitives via the `wrapping_mul` method. For example,
19711971
/// [`u32::wrapping_mul`]
19721972
#[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
1973-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1973+
#[rustc_safe_intrinsic]
19741974
pub fn wrapping_mul<T: Copy>(a: T, b: T) -> T;
19751975

19761976
/// Computes `a + b`, saturating at numeric bounds.
@@ -1984,7 +1984,7 @@ extern "rust-intrinsic" {
19841984
/// primitives via the `saturating_add` method. For example,
19851985
/// [`u32::saturating_add`]
19861986
#[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")]
1987-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
1987+
#[rustc_safe_intrinsic]
19881988
pub fn saturating_add<T: Copy>(a: T, b: T) -> T;
19891989
/// Computes `a - b`, saturating at numeric bounds.
19901990
///
@@ -1997,7 +1997,7 @@ extern "rust-intrinsic" {
19971997
/// primitives via the `saturating_sub` method. For example,
19981998
/// [`u32::saturating_sub`]
19991999
#[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")]
2000-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
2000+
#[rustc_safe_intrinsic]
20012001
pub fn saturating_sub<T: Copy>(a: T, b: T) -> T;
20022002

20032003
/// Returns the value of the discriminant for the variant in 'v';
@@ -2010,7 +2010,7 @@ extern "rust-intrinsic" {
20102010
///
20112011
/// The stabilized version of this intrinsic is [`core::mem::discriminant`].
20122012
#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
2013-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
2013+
#[rustc_safe_intrinsic]
20142014
pub fn discriminant_value<T>(v: &T) -> <T as DiscriminantKind>::Discriminant;
20152015

20162016
/// Returns the number of variants of the type `T` cast to a `usize`;
@@ -2023,7 +2023,7 @@ extern "rust-intrinsic" {
20232023
///
20242024
/// The to-be-stabilized version of this intrinsic is [`mem::variant_count`].
20252025
#[rustc_const_unstable(feature = "variant_count", issue = "73662")]
2026-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
2026+
#[rustc_safe_intrinsic]
20272027
pub fn variant_count<T>() -> usize;
20282028

20292029
/// Rust's "try catch" construct which invokes the function pointer `try_fn`
@@ -2057,7 +2057,7 @@ extern "rust-intrinsic" {
20572057
/// Therefore, implementations must not require the user to uphold
20582058
/// any safety invariants.
20592059
#[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
2060-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
2060+
#[rustc_safe_intrinsic]
20612061
pub fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8;
20622062

20632063
/// Allocates a block of memory at compile time.
@@ -2108,7 +2108,7 @@ extern "rust-intrinsic" {
21082108
///
21092109
/// [`std::hint::black_box`]: crate::hint::black_box
21102110
#[rustc_const_unstable(feature = "const_black_box", issue = "none")]
2111-
#[cfg_attr(not(bootstrap), rustc_safe_intrinsic)]
2111+
#[rustc_safe_intrinsic]
21122112
pub fn black_box<T>(dummy: T) -> T;
21132113

21142114
/// `ptr` must point to a vtable.

core/src/ops/deref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#[doc(alias = "&*")]
6262
#[stable(feature = "rust1", since = "1.0.0")]
6363
#[rustc_diagnostic_item = "Deref"]
64-
#[cfg_attr(not(bootstrap), const_trait)]
64+
#[const_trait]
6565
pub trait Deref {
6666
/// The resulting type after dereferencing.
6767
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)