Skip to content

Commit

Permalink
Rollup merge of rust-lang#57234 - Centril:const-stabilizations-2, r=o…
Browse files Browse the repository at this point in the history
…li-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`
  • Loading branch information
Centril authored Jan 11, 2019
2 parents 8087e72 + 14be8a7 commit 1b42fdf
Show file tree
Hide file tree
Showing 19 changed files with 669 additions and 198 deletions.
8 changes: 4 additions & 4 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ extern "rust-intrinsic" {
/// use std::intrinsics::ctlz;
///
/// let x = 0b0001_1100_u8;
/// let num_leading = unsafe { ctlz(x) };
/// let num_leading = ctlz(x);
/// assert_eq!(num_leading, 3);
/// ```
///
Expand All @@ -1360,7 +1360,7 @@ extern "rust-intrinsic" {
/// use std::intrinsics::ctlz;
///
/// let x = 0u16;
/// let num_leading = unsafe { ctlz(x) };
/// let num_leading = ctlz(x);
/// assert_eq!(num_leading, 16);
/// ```
pub fn ctlz<T>(x: T) -> T;
Expand Down Expand Up @@ -1391,7 +1391,7 @@ extern "rust-intrinsic" {
/// use std::intrinsics::cttz;
///
/// let x = 0b0011_1000_u8;
/// let num_trailing = unsafe { cttz(x) };
/// let num_trailing = cttz(x);
/// assert_eq!(num_trailing, 3);
/// ```
///
Expand All @@ -1403,7 +1403,7 @@ extern "rust-intrinsic" {
/// use std::intrinsics::cttz;
///
/// let x = 0u16;
/// let num_trailing = unsafe { cttz(x) };
/// let num_trailing = cttz(x);
/// assert_eq!(num_trailing, 16);
/// ```
pub fn cttz<T>(x: T) -> T;
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#![feature(cfg_target_has_atomic)]
#![feature(concat_idents)]
#![feature(const_fn)]
#![feature(const_int_ops)]
#![cfg_attr(stage0, feature(const_int_ops))]
#![feature(const_fn_union)]
#![feature(custom_attribute)]
#![feature(doc_cfg)]
Expand Down Expand Up @@ -114,9 +114,7 @@
#![feature(const_slice_len)]
#![feature(const_str_as_bytes)]
#![feature(const_str_len)]
#![feature(const_int_rotate)]
#![feature(const_int_wrapping)]
#![feature(const_int_sign)]
#![cfg_attr(stage0, feature(const_int_rotate))]
#![feature(const_int_conversion)]
#![feature(const_transmute)]
#![feature(reverse_bits)]
Expand Down
Loading

0 comments on commit 1b42fdf

Please sign in to comment.