Skip to content

Commit

Permalink
Stabilize unsigned num_midpoint feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Oct 16, 2024
1 parent f6648f2 commit 388f953
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 27 deletions.
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
#![feature(const_make_ascii)]
#![feature(const_maybe_uninit_assume_init)]
#![feature(const_nonnull_new)]
#![feature(const_num_midpoint)]
#![feature(const_option_ext)]
#![feature(const_pin)]
#![feature(const_pointer_is_aligned)]
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ impl f128 {
///
/// ```
/// #![feature(f128)]
/// #![feature(num_midpoint)]
/// # // Using aarch64 because `reliable_f128_math` is needed
/// # #[cfg(all(target_arch = "aarch64", target_os = "linux"))] {
///
Expand All @@ -830,7 +829,6 @@ impl f128 {
/// ```
#[inline]
#[unstable(feature = "f128", issue = "116909")]
// #[unstable(feature = "num_midpoint", issue = "110840")]
pub fn midpoint(self, other: f128) -> f128 {
const LO: f128 = f128::MIN_POSITIVE * 2.;
const HI: f128 = f128::MAX / 2.;
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// #![feature(num_midpoint)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
///
/// assert_eq!(1f16.midpoint(4.0), 2.5);
Expand All @@ -815,7 +814,6 @@ impl f16 {
/// ```
#[inline]
#[unstable(feature = "f16", issue = "116909")]
// #[unstable(feature = "num_midpoint", issue = "110840")]
pub fn midpoint(self, other: f16) -> f16 {
const LO: f16 = f16::MIN_POSITIVE * 2.;
const HI: f16 = f16::MAX / 2.;
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,11 @@ impl f32 {
/// # Examples
///
/// ```
/// #![feature(num_midpoint)]
/// assert_eq!(1f32.midpoint(4.0), 2.5);
/// assert_eq!((-5.5f32).midpoint(8.0), 1.25);
/// ```
#[inline]
#[unstable(feature = "num_midpoint", issue = "110840")]
#[stable(feature = "num_midpoint", since = "CURRENT_RUSTC_VERSION")]
pub fn midpoint(self, other: f32) -> f32 {
cfg_if! {
if #[cfg(any(
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,12 +1007,11 @@ impl f64 {
/// # Examples
///
/// ```
/// #![feature(num_midpoint)]
/// assert_eq!(1f64.midpoint(4.0), 2.5);
/// assert_eq!((-5.5f64).midpoint(8.0), 1.25);
/// ```
#[inline]
#[unstable(feature = "num_midpoint", issue = "110840")]
#[stable(feature = "num_midpoint", since = "CURRENT_RUSTC_VERSION")]
pub fn midpoint(self, other: f64) -> f64 {
const LO: f64 = f64::MIN_POSITIVE * 2.;
const HI: f64 = f64::MAX / 2.;
Expand Down
7 changes: 3 additions & 4 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3190,14 +3190,13 @@ macro_rules! int_impl {
/// # Examples
///
/// ```
/// #![feature(num_midpoint)]
/// #![feature(num_midpoint_signed)]
#[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")]
#[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(-1), -1);")]
#[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").midpoint(0), -1);")]
/// ```
#[unstable(feature = "num_midpoint", issue = "110840")]
#[rustc_const_unstable(feature = "const_num_midpoint", issue = "110840")]
#[rustc_allow_const_fn_unstable(const_num_midpoint)]
#[unstable(feature = "num_midpoint_signed", issue = "110840")]
#[rustc_const_unstable(feature = "num_midpoint_signed", issue = "110840")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand Down
14 changes: 6 additions & 8 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,17 @@ macro_rules! midpoint_impl {
/// Calculates the middle point of `self` and `rhs`.
///
/// `midpoint(a, b)` is `(a + b) >> 1` as if it were performed in a
/// sufficiently-large signed integral type. This implies that the result is
/// sufficiently-large unsigned integral type. This implies that the result is
/// always rounded towards negative infinity and that no overflow will ever occur.
///
/// # Examples
///
/// ```
/// #![feature(num_midpoint)]
#[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")]
#[doc = concat!("assert_eq!(1", stringify!($SelfT), ".midpoint(4), 2);")]
/// ```
#[unstable(feature = "num_midpoint", issue = "110840")]
#[rustc_const_unstable(feature = "const_num_midpoint", issue = "110840")]
#[stable(feature = "num_midpoint", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "const_num_midpoint", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand All @@ -135,18 +134,17 @@ macro_rules! midpoint_impl {
/// Calculates the middle point of `self` and `rhs`.
///
/// `midpoint(a, b)` is `(a + b) >> 1` as if it were performed in a
/// sufficiently-large signed integral type. This implies that the result is
/// sufficiently-large unsigned integral type. This implies that the result is
/// always rounded towards negative infinity and that no overflow will ever occur.
///
/// # Examples
///
/// ```
/// #![feature(num_midpoint)]
#[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")]
#[doc = concat!("assert_eq!(1", stringify!($SelfT), ".midpoint(4), 2);")]
/// ```
#[unstable(feature = "num_midpoint", issue = "110840")]
#[rustc_const_unstable(feature = "const_num_midpoint", issue = "110840")]
#[stable(feature = "num_midpoint", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "const_num_midpoint", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand Down
7 changes: 2 additions & 5 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,8 +1458,6 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// # Examples
///
/// ```
/// #![feature(num_midpoint)]
///
/// # use std::num::NonZero;
/// #
/// # fn main() { test().unwrap(); }
Expand All @@ -1473,9 +1471,8 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
/// # Some(())
/// # }
/// ```
#[unstable(feature = "num_midpoint", issue = "110840")]
#[rustc_const_unstable(feature = "const_num_midpoint", issue = "110840")]
#[rustc_allow_const_fn_unstable(const_num_midpoint)]
#[stable(feature = "num_midpoint", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "const_num_midpoint", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(noop_waker)]
#![feature(num_midpoint)]
#![feature(num_midpoint_signed)]
#![feature(numfmt)]
#![feature(pattern)]
#![feature(pointer_is_aligned_to)]
Expand Down

0 comments on commit 388f953

Please sign in to comment.