Skip to content

Commit 6c2c29c

Browse files
committed
Auto merge of #64766 - Centril:rollup-gdy5jr6, r=Centril
Rollup of 6 pull requests Successful merges: - #62975 (Almost fully deprecate hir::map::Map.hir_to_node_id) - #64386 (use `sign` variable in abs and wrapping_abs methods) - #64508 (or-patterns: Push `PatKind/PatternKind::Or` at top level to HIR & HAIR) - #64738 (Add const-eval support for SIMD types, insert, and extract) - #64759 (Refactor mbe a tiny bit) - #64764 (Master is now 1.40 ) Failed merges: r? @ghost
2 parents acf7b50 + 1e8dd37 commit 6c2c29c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+568
-667
lines changed

src/bootstrap/channel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use build_helper::output;
1313
use crate::Build;
1414

1515
// The version number
16-
pub const CFG_RELEASE_NUM: &str = "1.39.0";
16+
pub const CFG_RELEASE_NUM: &str = "1.40.0";
1717

1818
pub struct GitInfo {
1919
inner: Option<Info>,

src/liballoc/alloc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ pub(crate) unsafe fn box_free<T: ?Sized>(ptr: Unique<T>) {
240240
#[stable(feature = "global_alloc", since = "1.28.0")]
241241
#[rustc_allocator_nounwind]
242242
pub fn handle_alloc_error(layout: Layout) -> ! {
243-
#[cfg_attr(bootstrap, allow(improper_ctypes))]
244243
extern "Rust" {
245244
#[lang = "oom"]
246245
fn oom_impl(layout: Layout) -> !;

src/liballoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117
#![feature(allocator_internals)]
118118
#![feature(on_unimplemented)]
119119
#![feature(rustc_const_unstable)]
120-
#![cfg_attr(bootstrap, feature(const_vec_new))]
121120
#![feature(slice_partition_dedup)]
122121
#![feature(maybe_uninit_extra, maybe_uninit_slice)]
123122
#![feature(alloc_layout_extra)]

src/liballoc/string.rs

-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ impl String {
369369
/// ```
370370
#[inline]
371371
#[stable(feature = "rust1", since = "1.0.0")]
372-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_string_new"))]
373372
pub const fn new() -> String {
374373
String { vec: Vec::new() }
375374
}

src/liballoc/vec.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ use crate::raw_vec::RawVec;
291291
/// [`reserve`]: ../../std/vec/struct.Vec.html#method.reserve
292292
/// [owned slice]: ../../std/boxed/struct.Box.html
293293
#[stable(feature = "rust1", since = "1.0.0")]
294-
#[cfg_attr(all(not(bootstrap), not(test)), rustc_diagnostic_item = "vec_type")]
294+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_type")]
295295
pub struct Vec<T> {
296296
buf: RawVec<T>,
297297
len: usize,
@@ -314,7 +314,6 @@ impl<T> Vec<T> {
314314
/// ```
315315
#[inline]
316316
#[stable(feature = "rust1", since = "1.0.0")]
317-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_vec_new"))]
318317
pub const fn new() -> Vec<T> {
319318
Vec {
320319
buf: RawVec::NEW,

src/libcore/bool.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! impl bool {}
22
3-
#[cfg(not(bootstrap))]
43
#[lang = "bool"]
54
impl bool {
65
/// Returns `Some(t)` if the `bool` is `true`, or `None` otherwise.

src/libcore/clone.rs

-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ pub trait Clone : Sized {
135135

136136
/// Derive macro generating an impl of the trait `Clone`.
137137
#[rustc_builtin_macro]
138-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
139138
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
140139
#[allow_internal_unstable(core_intrinsics, derive_clone_copy)]
141140
pub macro Clone($item:item) { /* compiler built-in */ }

src/libcore/cmp.rs

-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
210210

211211
/// Derive macro generating an impl of the trait `PartialEq`.
212212
#[rustc_builtin_macro]
213-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
214213
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
215214
#[allow_internal_unstable(core_intrinsics)]
216215
pub macro PartialEq($item:item) { /* compiler built-in */ }
@@ -273,7 +272,6 @@ pub trait Eq: PartialEq<Self> {
273272

274273
/// Derive macro generating an impl of the trait `Eq`.
275274
#[rustc_builtin_macro]
276-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
277275
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
278276
#[allow_internal_unstable(core_intrinsics, derive_eq)]
279277
pub macro Eq($item:item) { /* compiler built-in */ }
@@ -624,7 +622,6 @@ pub trait Ord: Eq + PartialOrd<Self> {
624622

625623
/// Derive macro generating an impl of the trait `Ord`.
626624
#[rustc_builtin_macro]
627-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
628625
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
629626
#[allow_internal_unstable(core_intrinsics)]
630627
pub macro Ord($item:item) { /* compiler built-in */ }
@@ -873,7 +870,6 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
873870

874871
/// Derive macro generating an impl of the trait `PartialOrd`.
875872
#[rustc_builtin_macro]
876-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
877873
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
878874
#[allow_internal_unstable(core_intrinsics)]
879875
pub macro PartialOrd($item:item) { /* compiler built-in */ }

src/libcore/default.rs

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ pub trait Default: Sized {
117117

118118
/// Derive macro generating an impl of the trait `Default`.
119119
#[rustc_builtin_macro]
120-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
121120
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
122121
#[allow_internal_unstable(core_intrinsics)]
123122
pub macro Default($item:item) { /* compiler built-in */ }

src/libcore/fmt/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ impl Display for Arguments<'_> {
518518
label="`{Self}` cannot be formatted using `{{:?}}` because it doesn't implement `{Debug}`",
519519
)]
520520
#[doc(alias = "{:?}")]
521-
#[cfg_attr(bootstrap, lang = "debug_trait")]
522-
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "debug_trait")]
521+
#[rustc_diagnostic_item = "debug_trait"]
523522
pub trait Debug {
524523
/// Formats the value using the given formatter.
525524
///
@@ -550,7 +549,6 @@ pub trait Debug {
550549
pub(crate) mod macros {
551550
/// Derive macro generating an impl of the trait `Debug`.
552551
#[rustc_builtin_macro]
553-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
554552
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
555553
#[allow_internal_unstable(core_intrinsics)]
556554
pub macro Debug($item:item) { /* compiler built-in */ }

src/libcore/hash/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ pub trait Hash {
202202
pub(crate) mod macros {
203203
/// Derive macro generating an impl of the trait `Hash`.
204204
#[rustc_builtin_macro]
205-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
206205
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
207206
#[allow_internal_unstable(core_intrinsics)]
208207
pub macro Hash($item:item) { /* compiler built-in */ }

src/libcore/intrinsics.rs

-22
Original file line numberDiff line numberDiff line change
@@ -1299,38 +1299,16 @@ extern "rust-intrinsic" {
12991299
/// The stabilized versions of this intrinsic are available on the integer
13001300
/// primitives via the `wrapping_add` method. For example,
13011301
/// [`std::u32::wrapping_add`](../../std/primitive.u32.html#method.wrapping_add)
1302-
#[cfg(bootstrap)]
1303-
pub fn overflowing_add<T>(a: T, b: T) -> T;
1304-
/// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
1305-
/// The stabilized versions of this intrinsic are available on the integer
1306-
/// primitives via the `wrapping_sub` method. For example,
1307-
/// [`std::u32::wrapping_sub`](../../std/primitive.u32.html#method.wrapping_sub)
1308-
#[cfg(bootstrap)]
1309-
pub fn overflowing_sub<T>(a: T, b: T) -> T;
1310-
/// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
1311-
/// The stabilized versions of this intrinsic are available on the integer
1312-
/// primitives via the `wrapping_mul` method. For example,
1313-
/// [`std::u32::wrapping_mul`](../../std/primitive.u32.html#method.wrapping_mul)
1314-
#[cfg(bootstrap)]
1315-
pub fn overflowing_mul<T>(a: T, b: T) -> T;
1316-
1317-
/// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
1318-
/// The stabilized versions of this intrinsic are available on the integer
1319-
/// primitives via the `wrapping_add` method. For example,
1320-
/// [`std::u32::wrapping_add`](../../std/primitive.u32.html#method.wrapping_add)
1321-
#[cfg(not(bootstrap))]
13221302
pub fn wrapping_add<T>(a: T, b: T) -> T;
13231303
/// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
13241304
/// The stabilized versions of this intrinsic are available on the integer
13251305
/// primitives via the `wrapping_sub` method. For example,
13261306
/// [`std::u32::wrapping_sub`](../../std/primitive.u32.html#method.wrapping_sub)
1327-
#[cfg(not(bootstrap))]
13281307
pub fn wrapping_sub<T>(a: T, b: T) -> T;
13291308
/// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
13301309
/// The stabilized versions of this intrinsic are available on the integer
13311310
/// primitives via the `wrapping_mul` method. For example,
13321311
/// [`std::u32::wrapping_mul`](../../std/primitive.u32.html#method.wrapping_mul)
1333-
#[cfg(not(bootstrap))]
13341312
pub fn wrapping_mul<T>(a: T, b: T) -> T;
13351313

13361314
/// Computes `a + b`, while saturating at numeric bounds.

src/libcore/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
#![feature(link_llvm_intrinsics)]
8888
#![feature(never_type)]
8989
#![feature(nll)]
90-
#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))]
9190
#![feature(exhaustive_patterns)]
9291
#![feature(no_core)]
9392
#![feature(on_unimplemented)]
@@ -120,9 +119,6 @@
120119
#![feature(rtm_target_feature)]
121120
#![feature(f16c_target_feature)]
122121
#![feature(hexagon_target_feature)]
123-
#![cfg_attr(bootstrap, feature(const_slice_len))]
124-
#![cfg_attr(bootstrap, feature(const_str_as_bytes))]
125-
#![cfg_attr(bootstrap, feature(const_str_len))]
126122
#![feature(const_int_conversion)]
127123
#![feature(const_transmute)]
128124
#![feature(non_exhaustive)]

src/libcore/macros.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1236,10 +1236,8 @@ pub(crate) mod builtin {
12361236
pub macro test($item:item) { /* compiler built-in */ }
12371237

12381238
/// Attribute macro applied to a function to turn it into a benchmark test.
1239-
#[cfg_attr(not(bootstrap), unstable(soft, feature = "test", issue = "50297",
1240-
reason = "`bench` is a part of custom test frameworks which are unstable"))]
1241-
#[cfg_attr(bootstrap, unstable(feature = "test", issue = "50297",
1242-
reason = "`bench` is a part of custom test frameworks which are unstable"))]
1239+
#[unstable(soft, feature = "test", issue = "50297",
1240+
reason = "`bench` is a part of custom test frameworks which are unstable")]
12431241
#[allow_internal_unstable(test, rustc_attrs)]
12441242
#[rustc_builtin_macro]
12451243
pub macro bench($item:item) { /* compiler built-in */ }

src/libcore/marker.rs

-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ pub trait Copy : Clone {
290290

291291
/// Derive macro generating an impl of the trait `Copy`.
292292
#[rustc_builtin_macro]
293-
#[cfg_attr(bootstrap, rustc_macro_transparency = "semitransparent")]
294293
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
295294
#[allow_internal_unstable(core_intrinsics, derive_clone_copy)]
296295
pub macro Copy($item:item) { /* compiler built-in */ }

src/libcore/num/mod.rs

+32-45
Original file line numberDiff line numberDiff line change
@@ -1112,13 +1112,7 @@ $EndFeature, "
11121112
without modifying the original"]
11131113
#[inline]
11141114
pub const fn wrapping_add(self, rhs: Self) -> Self {
1115-
#[cfg(bootstrap)] {
1116-
intrinsics::overflowing_add(self, rhs)
1117-
}
1118-
1119-
#[cfg(not(bootstrap))] {
1120-
intrinsics::wrapping_add(self, rhs)
1121-
}
1115+
intrinsics::wrapping_add(self, rhs)
11221116
}
11231117
}
11241118

@@ -1141,13 +1135,7 @@ $EndFeature, "
11411135
without modifying the original"]
11421136
#[inline]
11431137
pub const fn wrapping_sub(self, rhs: Self) -> Self {
1144-
#[cfg(bootstrap)] {
1145-
intrinsics::overflowing_sub(self, rhs)
1146-
}
1147-
1148-
#[cfg(not(bootstrap))] {
1149-
intrinsics::wrapping_sub(self, rhs)
1150-
}
1138+
intrinsics::wrapping_sub(self, rhs)
11511139
}
11521140
}
11531141

@@ -1169,13 +1157,7 @@ $EndFeature, "
11691157
without modifying the original"]
11701158
#[inline]
11711159
pub const fn wrapping_mul(self, rhs: Self) -> Self {
1172-
#[cfg(bootstrap)] {
1173-
intrinsics::overflowing_mul(self, rhs)
1174-
}
1175-
1176-
#[cfg(not(bootstrap))] {
1177-
intrinsics::wrapping_mul(self, rhs)
1178-
}
1160+
intrinsics::wrapping_mul(self, rhs)
11791161
}
11801162
}
11811163

@@ -1402,7 +1384,16 @@ $EndFeature, "
14021384
#[stable(feature = "no_panic_abs", since = "1.13.0")]
14031385
#[inline]
14041386
pub const fn wrapping_abs(self) -> Self {
1405-
(self ^ (self >> ($BITS - 1))).wrapping_sub(self >> ($BITS - 1))
1387+
// sign is -1 (all ones) for negative numbers, 0 otherwise.
1388+
let sign = self >> ($BITS - 1);
1389+
// For positive self, sign == 0 so the expression is simply
1390+
// (self ^ 0).wrapping_sub(0) == self == abs(self).
1391+
//
1392+
// For negative self, self ^ sign == self ^ all_ones.
1393+
// But all_ones ^ self == all_ones - self == -1 - self.
1394+
// So for negative numbers, (self ^ sign).wrapping_sub(sign) is
1395+
// (-1 - self).wrapping_sub(-1) == -self == abs(self).
1396+
(self ^ sign).wrapping_sub(sign)
14061397
}
14071398
}
14081399

@@ -1761,7 +1752,7 @@ $EndFeature, "
17611752
#[stable(feature = "no_panic_abs", since = "1.13.0")]
17621753
#[inline]
17631754
pub const fn overflowing_abs(self) -> (Self, bool) {
1764-
(self ^ (self >> ($BITS - 1))).overflowing_sub(self >> ($BITS - 1))
1755+
(self.wrapping_abs(), self == Self::min_value())
17651756
}
17661757
}
17671758

@@ -1969,7 +1960,21 @@ $EndFeature, "
19691960
// Note that the #[inline] above means that the overflow
19701961
// semantics of the subtraction depend on the crate we're being
19711962
// inlined into.
1972-
(self ^ (self >> ($BITS - 1))) - (self >> ($BITS - 1))
1963+
1964+
// sign is -1 (all ones) for negative numbers, 0 otherwise.
1965+
let sign = self >> ($BITS - 1);
1966+
// For positive self, sign == 0 so the expression is simply
1967+
// (self ^ 0) - 0 == self == abs(self).
1968+
//
1969+
// For negative self, self ^ sign == self ^ all_ones.
1970+
// But all_ones ^ self == all_ones - self == -1 - self.
1971+
// So for negative numbers, (self ^ sign) - sign is
1972+
// (-1 - self) - -1 == -self == abs(self).
1973+
//
1974+
// The subtraction overflows when self is min_value(), because
1975+
// (-1 - min_value()) - -1 is max_value() - -1 which overflows.
1976+
// This is exactly when we want self.abs() to overflow.
1977+
(self ^ sign) - sign
19731978
}
19741979
}
19751980

@@ -3040,13 +3045,7 @@ $EndFeature, "
30403045
without modifying the original"]
30413046
#[inline]
30423047
pub const fn wrapping_add(self, rhs: Self) -> Self {
3043-
#[cfg(bootstrap)] {
3044-
intrinsics::overflowing_add(self, rhs)
3045-
}
3046-
3047-
#[cfg(not(bootstrap))] {
3048-
intrinsics::wrapping_add(self, rhs)
3049-
}
3048+
intrinsics::wrapping_add(self, rhs)
30503049
}
30513050
}
30523051

@@ -3068,13 +3067,7 @@ $EndFeature, "
30683067
without modifying the original"]
30693068
#[inline]
30703069
pub const fn wrapping_sub(self, rhs: Self) -> Self {
3071-
#[cfg(bootstrap)] {
3072-
intrinsics::overflowing_sub(self, rhs)
3073-
}
3074-
3075-
#[cfg(not(bootstrap))] {
3076-
intrinsics::wrapping_sub(self, rhs)
3077-
}
3070+
intrinsics::wrapping_sub(self, rhs)
30783071
}
30793072
}
30803073

@@ -3097,13 +3090,7 @@ $EndFeature, "
30973090
without modifying the original"]
30983091
#[inline]
30993092
pub const fn wrapping_mul(self, rhs: Self) -> Self {
3100-
#[cfg(bootstrap)] {
3101-
intrinsics::overflowing_mul(self, rhs)
3102-
}
3103-
3104-
#[cfg(not(bootstrap))] {
3105-
intrinsics::wrapping_mul(self, rhs)
3106-
}
3093+
intrinsics::wrapping_mul(self, rhs)
31073094
}
31083095

31093096
doc_comment! {

src/libcore/panicking.rs

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>, file_line_col: &(&'static str, u32, u3
7171
}
7272

7373
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
74-
#[cfg_attr(bootstrap, allow(improper_ctypes))]
7574
extern "Rust" {
7675
#[lang = "panic_impl"]
7776
fn panic_impl(pi: &PanicInfo<'_>) -> !;

src/libcore/slice/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ impl<T> [T] {
6262
/// ```
6363
#[stable(feature = "rust1", since = "1.0.0")]
6464
#[inline]
65-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_slice_len"))]
6665
// SAFETY: const sound because we transmute out the length field as a usize (which it must be)
67-
#[cfg_attr(not(bootstrap), allow_internal_unstable(const_fn_union))]
66+
#[allow_internal_unstable(const_fn_union)]
6867
pub const fn len(&self) -> usize {
6968
unsafe {
7069
crate::ptr::Repr { rust: self }.raw.len
@@ -81,7 +80,6 @@ impl<T> [T] {
8180
/// ```
8281
#[stable(feature = "rust1", since = "1.0.0")]
8382
#[inline]
84-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_slice_len"))]
8583
pub const fn is_empty(&self) -> bool {
8684
self.len() == 0
8785
}

0 commit comments

Comments
 (0)