Skip to content

Commit b8dab92

Browse files
committed
Auto merge of rust-lang#124302 - matthiaskrgr:rollup-2aya8n8, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang#124003 (Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics)) - rust-lang#124169 (Don't fatal when calling `expect_one_of` when recovering arg in `parse_seq`) - rust-lang#124286 (Subtree sync for rustc_codegen_cranelift) r? `@ghost` `@rustbot` modify labels: rollup
2 parents eb97638 + 86d0c93 commit b8dab92

File tree

3 files changed

+79
-7
lines changed

3 files changed

+79
-7
lines changed

core/src/intrinsics.rs

+47
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,13 @@ extern "rust-intrinsic" {
19871987
/// The stabilized versions of this intrinsic are available on the integer
19881988
/// primitives via the `count_ones` method. For example,
19891989
/// [`u32::count_ones`]
1990+
#[cfg(not(bootstrap))]
1991+
#[rustc_const_stable(feature = "const_ctpop", since = "1.40.0")]
1992+
#[rustc_safe_intrinsic]
1993+
#[rustc_nounwind]
1994+
pub fn ctpop<T: Copy>(x: T) -> u32;
1995+
1996+
#[cfg(bootstrap)]
19901997
#[rustc_const_stable(feature = "const_ctpop", since = "1.40.0")]
19911998
#[rustc_safe_intrinsic]
19921999
#[rustc_nounwind]
@@ -2028,6 +2035,13 @@ extern "rust-intrinsic" {
20282035
/// let num_leading = ctlz(x);
20292036
/// assert_eq!(num_leading, 16);
20302037
/// ```
2038+
#[cfg(not(bootstrap))]
2039+
#[rustc_const_stable(feature = "const_ctlz", since = "1.40.0")]
2040+
#[rustc_safe_intrinsic]
2041+
#[rustc_nounwind]
2042+
pub fn ctlz<T: Copy>(x: T) -> u32;
2043+
2044+
#[cfg(bootstrap)]
20312045
#[rustc_const_stable(feature = "const_ctlz", since = "1.40.0")]
20322046
#[rustc_safe_intrinsic]
20332047
#[rustc_nounwind]
@@ -2050,6 +2064,12 @@ extern "rust-intrinsic" {
20502064
/// let num_leading = unsafe { ctlz_nonzero(x) };
20512065
/// assert_eq!(num_leading, 3);
20522066
/// ```
2067+
#[cfg(not(bootstrap))]
2068+
#[rustc_const_stable(feature = "constctlz", since = "1.50.0")]
2069+
#[rustc_nounwind]
2070+
pub fn ctlz_nonzero<T: Copy>(x: T) -> u32;
2071+
2072+
#[cfg(bootstrap)]
20532073
#[rustc_const_stable(feature = "constctlz", since = "1.50.0")]
20542074
#[rustc_nounwind]
20552075
pub fn ctlz_nonzero<T: Copy>(x: T) -> T;
@@ -2090,6 +2110,13 @@ extern "rust-intrinsic" {
20902110
/// let num_trailing = cttz(x);
20912111
/// assert_eq!(num_trailing, 16);
20922112
/// ```
2113+
#[cfg(not(bootstrap))]
2114+
#[rustc_const_stable(feature = "const_cttz", since = "1.40.0")]
2115+
#[rustc_safe_intrinsic]
2116+
#[rustc_nounwind]
2117+
pub fn cttz<T: Copy>(x: T) -> u32;
2118+
2119+
#[cfg(bootstrap)]
20932120
#[rustc_const_stable(feature = "const_cttz", since = "1.40.0")]
20942121
#[rustc_safe_intrinsic]
20952122
#[rustc_nounwind]
@@ -2112,6 +2139,12 @@ extern "rust-intrinsic" {
21122139
/// let num_trailing = unsafe { cttz_nonzero(x) };
21132140
/// assert_eq!(num_trailing, 3);
21142141
/// ```
2142+
#[cfg(not(bootstrap))]
2143+
#[rustc_const_stable(feature = "const_cttz_nonzero", since = "1.53.0")]
2144+
#[rustc_nounwind]
2145+
pub fn cttz_nonzero<T: Copy>(x: T) -> u32;
2146+
2147+
#[cfg(bootstrap)]
21152148
#[rustc_const_stable(feature = "const_cttz_nonzero", since = "1.53.0")]
21162149
#[rustc_nounwind]
21172150
pub fn cttz_nonzero<T: Copy>(x: T) -> T;
@@ -2288,6 +2321,13 @@ extern "rust-intrinsic" {
22882321
/// The stabilized versions of this intrinsic are available on the integer
22892322
/// primitives via the `rotate_left` method. For example,
22902323
/// [`u32::rotate_left`]
2324+
#[cfg(not(bootstrap))]
2325+
#[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
2326+
#[rustc_safe_intrinsic]
2327+
#[rustc_nounwind]
2328+
pub fn rotate_left<T: Copy>(x: T, shift: u32) -> T;
2329+
2330+
#[cfg(bootstrap)]
22912331
#[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
22922332
#[rustc_safe_intrinsic]
22932333
#[rustc_nounwind]
@@ -2303,6 +2343,13 @@ extern "rust-intrinsic" {
23032343
/// The stabilized versions of this intrinsic are available on the integer
23042344
/// primitives via the `rotate_right` method. For example,
23052345
/// [`u32::rotate_right`]
2346+
#[cfg(not(bootstrap))]
2347+
#[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
2348+
#[rustc_safe_intrinsic]
2349+
#[rustc_nounwind]
2350+
pub fn rotate_right<T: Copy>(x: T, shift: u32) -> T;
2351+
2352+
#[cfg(bootstrap)]
23062353
#[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
23072354
#[rustc_safe_intrinsic]
23082355
#[rustc_nounwind]

core/src/num/nonzero.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,12 @@ macro_rules! nonzero_integer {
527527
#[inline]
528528
pub const fn leading_zeros(self) -> u32 {
529529
// SAFETY: since `self` cannot be zero, it is safe to call `ctlz_nonzero`.
530-
unsafe { intrinsics::ctlz_nonzero(self.get() as $UnsignedPrimitive) as u32 }
530+
unsafe {
531+
#[cfg(not(bootstrap))]
532+
return intrinsics::ctlz_nonzero(self.get() as $UnsignedPrimitive);
533+
#[cfg(bootstrap)]
534+
return intrinsics::ctlz_nonzero(self.get() as $UnsignedPrimitive) as u32;
535+
}
531536
}
532537

533538
/// Returns the number of trailing zeros in the binary representation
@@ -551,7 +556,12 @@ macro_rules! nonzero_integer {
551556
#[inline]
552557
pub const fn trailing_zeros(self) -> u32 {
553558
// SAFETY: since `self` cannot be zero, it is safe to call `cttz_nonzero`.
554-
unsafe { intrinsics::cttz_nonzero(self.get() as $UnsignedPrimitive) as u32 }
559+
unsafe {
560+
#[cfg(not(bootstrap))]
561+
return intrinsics::cttz_nonzero(self.get() as $UnsignedPrimitive);
562+
#[cfg(bootstrap)]
563+
return intrinsics::cttz_nonzero(self.get() as $UnsignedPrimitive) as u32;
564+
}
555565
}
556566

557567
/// Returns the number of ones in the binary representation of `self`.

core/src/num/uint_macros.rs

+20-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ macro_rules! uint_impl {
7777
without modifying the original"]
7878
#[inline(always)]
7979
pub const fn count_ones(self) -> u32 {
80-
intrinsics::ctpop(self as $ActualT) as u32
80+
#[cfg(not(bootstrap))]
81+
return intrinsics::ctpop(self as $ActualT);
82+
#[cfg(bootstrap)]
83+
return intrinsics::ctpop(self as $ActualT) as u32;
8184
}
8285

8386
/// Returns the number of zeros in the binary representation of `self`.
@@ -119,7 +122,10 @@ macro_rules! uint_impl {
119122
without modifying the original"]
120123
#[inline(always)]
121124
pub const fn leading_zeros(self) -> u32 {
122-
intrinsics::ctlz(self as $ActualT) as u32
125+
#[cfg(not(bootstrap))]
126+
return intrinsics::ctlz(self as $ActualT);
127+
#[cfg(bootstrap)]
128+
return intrinsics::ctlz(self as $ActualT) as u32;
123129
}
124130

125131
/// Returns the number of trailing zeros in the binary representation
@@ -140,7 +146,10 @@ macro_rules! uint_impl {
140146
without modifying the original"]
141147
#[inline(always)]
142148
pub const fn trailing_zeros(self) -> u32 {
143-
intrinsics::cttz(self) as u32
149+
#[cfg(not(bootstrap))]
150+
return intrinsics::cttz(self);
151+
#[cfg(bootstrap)]
152+
return intrinsics::cttz(self) as u32;
144153
}
145154

146155
/// Returns the number of leading ones in the binary representation of `self`.
@@ -205,7 +214,10 @@ macro_rules! uint_impl {
205214
without modifying the original"]
206215
#[inline(always)]
207216
pub const fn rotate_left(self, n: u32) -> Self {
208-
intrinsics::rotate_left(self, n as $SelfT)
217+
#[cfg(not(bootstrap))]
218+
return intrinsics::rotate_left(self, n);
219+
#[cfg(bootstrap)]
220+
return intrinsics::rotate_left(self, n as $SelfT);
209221
}
210222

211223
/// Shifts the bits to the right by a specified amount, `n`,
@@ -230,7 +242,10 @@ macro_rules! uint_impl {
230242
without modifying the original"]
231243
#[inline(always)]
232244
pub const fn rotate_right(self, n: u32) -> Self {
233-
intrinsics::rotate_right(self, n as $SelfT)
245+
#[cfg(not(bootstrap))]
246+
return intrinsics::rotate_right(self, n);
247+
#[cfg(bootstrap)]
248+
return intrinsics::rotate_right(self, n as $SelfT);
234249
}
235250

236251
/// Reverses the byte order of the integer.

0 commit comments

Comments
 (0)