Skip to content

Commit

Permalink
Rollup merge of rust-lang#131289 - RalfJung:duration_consts_float, r=…
Browse files Browse the repository at this point in the history
…tgross35

stabilize duration_consts_float

Waiting for FCP in rust-lang#72440 to pass.

`as_millis_f32` and `as_millis_f64` are not stable at all yet, so I moved their const-stability together with their regular stability (tracked at rust-lang#122451).

Fixes rust-lang#72440
  • Loading branch information
tgross35 authored Oct 12, 2024
2 parents de76914 + 12b8028 commit 4f124de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
#![feature(const_unicode_case_lookup)]
#![feature(coverage_attribute)]
#![feature(do_not_recommend)]
#![feature(duration_consts_float)]
#![feature(internal_impls_macro)]
#![feature(ip)]
#![feature(is_ascii_octdigit)]
Expand Down
12 changes: 6 additions & 6 deletions core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ impl Duration {
#[stable(feature = "duration_float", since = "1.38.0")]
#[must_use]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
#[rustc_const_stable(feature = "duration_consts_float", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_secs_f64(&self) -> f64 {
(self.secs as f64) + (self.nanos.0 as f64) / (NANOS_PER_SEC as f64)
}
Expand All @@ -866,7 +866,7 @@ impl Duration {
#[stable(feature = "duration_float", since = "1.38.0")]
#[must_use]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
#[rustc_const_stable(feature = "duration_consts_float", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_secs_f32(&self) -> f32 {
(self.secs as f32) + (self.nanos.0 as f32) / (NANOS_PER_SEC as f32)
}
Expand All @@ -886,7 +886,7 @@ impl Duration {
#[unstable(feature = "duration_millis_float", issue = "122451")]
#[must_use]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
#[rustc_const_unstable(feature = "duration_millis_float", issue = "122451")]
pub const fn as_millis_f64(&self) -> f64 {
(self.secs as f64) * (MILLIS_PER_SEC as f64)
+ (self.nanos.0 as f64) / (NANOS_PER_MILLI as f64)
Expand All @@ -907,7 +907,7 @@ impl Duration {
#[unstable(feature = "duration_millis_float", issue = "122451")]
#[must_use]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
#[rustc_const_unstable(feature = "duration_millis_float", issue = "122451")]
pub const fn as_millis_f32(&self) -> f32 {
(self.secs as f32) * (MILLIS_PER_SEC as f32)
+ (self.nanos.0 as f32) / (NANOS_PER_MILLI as f32)
Expand Down Expand Up @@ -1087,7 +1087,7 @@ impl Duration {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
#[rustc_const_stable(feature = "duration_consts_float", since = "CURRENT_RUSTC_VERSION")]
pub const fn div_duration_f64(self, rhs: Duration) -> f64 {
let self_nanos = (self.secs as f64) * (NANOS_PER_SEC as f64) + (self.nanos.0 as f64);
let rhs_nanos = (rhs.secs as f64) * (NANOS_PER_SEC as f64) + (rhs.nanos.0 as f64);
Expand All @@ -1108,7 +1108,7 @@ impl Duration {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_float", issue = "72440")]
#[rustc_const_stable(feature = "duration_consts_float", since = "CURRENT_RUSTC_VERSION")]
pub const fn div_duration_f32(self, rhs: Duration) -> f32 {
let self_nanos = (self.secs as f32) * (NANOS_PER_SEC as f32) + (self.nanos.0 as f32);
let rhs_nanos = (rhs.secs as f32) * (NANOS_PER_SEC as f32) + (rhs.nanos.0 as f32);
Expand Down
1 change: 0 additions & 1 deletion core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#![feature(dec2flt)]
#![feature(duration_constants)]
#![feature(duration_constructors)]
#![feature(duration_consts_float)]
#![feature(error_generic_member_access)]
#![feature(exact_size_is_empty)]
#![feature(extern_types)]
Expand Down

0 comments on commit 4f124de

Please sign in to comment.