Skip to content

Commit 2d99a86

Browse files
committed
stabilize const_cttz
1 parent ea1252e commit 2d99a86

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ extern "rust-intrinsic" {
15431543
/// let num_trailing = unsafe { cttz_nonzero(x) };
15441544
/// assert_eq!(num_trailing, 3);
15451545
/// ```
1546-
#[rustc_const_unstable(feature = "const_cttz", issue = "none")]
1546+
#[rustc_const_stable(feature = "const_cttz", since = "1.53.0")]
15471547
pub fn cttz_nonzero<T: Copy>(x: T) -> T;
15481548

15491549
/// Reverses the bytes in an integer type `T`.

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
#![feature(const_int_unchecked_arith)]
8080
#![feature(const_mut_refs)]
8181
#![feature(const_refs_to_cell)]
82-
#![feature(const_cttz)]
8382
#![feature(const_panic)]
8483
#![feature(const_pin)]
8584
#![feature(const_fn)]

src/test/ui/consts/const-int-unchecked.rs

+9
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,13 @@ const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) };
186186
//~^ ERROR any use of this value will cause an error
187187
//~| WARN this was previously accepted by the compiler but is being phased out
188188

189+
// capture fault with zero value
190+
191+
const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) };
192+
//~^ ERROR any use of this value will cause an error
193+
//~| WARN this was previously accepted by the compiler but is being phased out
194+
const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) };
195+
//~^ ERROR any use of this value will cause an error
196+
//~| WARN this was previously accepted by the compiler but is being phased out
197+
189198
fn main() {}

src/test/ui/consts/const-int-unchecked.stderr

+23-1
Original file line numberDiff line numberDiff line change
@@ -516,5 +516,27 @@ LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) };
516516
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
517517
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
518518

519-
error: aborting due to 47 previous errors
519+
error: any use of this value will cause an error
520+
--> $DIR/const-int-unchecked.rs:191:25
521+
|
522+
LL | const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) };
523+
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
524+
| |
525+
| `ctlz_nonzero` called on 0
526+
|
527+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
528+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
529+
530+
error: any use of this value will cause an error
531+
--> $DIR/const-int-unchecked.rs:194:25
532+
|
533+
LL | const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) };
534+
| ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
535+
| |
536+
| `cttz_nonzero` called on 0
537+
|
538+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
539+
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
540+
541+
error: aborting due to 49 previous errors
520542

0 commit comments

Comments
 (0)