Skip to content

Commit 1b42fdf

Browse files
authored
Rollup merge of rust-lang#57234 - Centril:const-stabilizations-2, r=oli-obk
Const-stabilize `const_int_ops` + `const_ip` r? @oli-obk I've added T-lang since this affects intrinsics and the operational semantics of Rust's `const fn` fragment. This PR depends on rust-lang#57105 but the FCP intent does not. ## Stable APIs proposed for constification + `const_int_ops`: + `count_ones` + `count_zeros` + `leading_zeros` + `trailing_zeros` + `swap_bytes` + `from_be` + `from_le` + `to_be` + `to_le` + `const_ip` + `Ipv4Addr::new` ## Unstable APIs constified + `const_int_conversion`: + `reverse_bits`
2 parents 8087e72 + 14be8a7 commit 1b42fdf

19 files changed

+669
-198
lines changed

src/libcore/intrinsics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ extern "rust-intrinsic" {
13481348
/// use std::intrinsics::ctlz;
13491349
///
13501350
/// let x = 0b0001_1100_u8;
1351-
/// let num_leading = unsafe { ctlz(x) };
1351+
/// let num_leading = ctlz(x);
13521352
/// assert_eq!(num_leading, 3);
13531353
/// ```
13541354
///
@@ -1360,7 +1360,7 @@ extern "rust-intrinsic" {
13601360
/// use std::intrinsics::ctlz;
13611361
///
13621362
/// let x = 0u16;
1363-
/// let num_leading = unsafe { ctlz(x) };
1363+
/// let num_leading = ctlz(x);
13641364
/// assert_eq!(num_leading, 16);
13651365
/// ```
13661366
pub fn ctlz<T>(x: T) -> T;
@@ -1391,7 +1391,7 @@ extern "rust-intrinsic" {
13911391
/// use std::intrinsics::cttz;
13921392
///
13931393
/// let x = 0b0011_1000_u8;
1394-
/// let num_trailing = unsafe { cttz(x) };
1394+
/// let num_trailing = cttz(x);
13951395
/// assert_eq!(num_trailing, 3);
13961396
/// ```
13971397
///
@@ -1403,7 +1403,7 @@ extern "rust-intrinsic" {
14031403
/// use std::intrinsics::cttz;
14041404
///
14051405
/// let x = 0u16;
1406-
/// let num_trailing = unsafe { cttz(x) };
1406+
/// let num_trailing = cttz(x);
14071407
/// assert_eq!(num_trailing, 16);
14081408
/// ```
14091409
pub fn cttz<T>(x: T) -> T;

src/libcore/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
#![feature(cfg_target_has_atomic)]
7272
#![feature(concat_idents)]
7373
#![feature(const_fn)]
74-
#![feature(const_int_ops)]
74+
#![cfg_attr(stage0, feature(const_int_ops))]
7575
#![feature(const_fn_union)]
7676
#![feature(custom_attribute)]
7777
#![feature(doc_cfg)]
@@ -114,9 +114,7 @@
114114
#![feature(const_slice_len)]
115115
#![feature(const_str_as_bytes)]
116116
#![feature(const_str_len)]
117-
#![feature(const_int_rotate)]
118-
#![feature(const_int_wrapping)]
119-
#![feature(const_int_sign)]
117+
#![cfg_attr(stage0, feature(const_int_rotate))]
120118
#![feature(const_int_conversion)]
121119
#![feature(const_transmute)]
122120
#![feature(reverse_bits)]

0 commit comments

Comments
 (0)