Skip to content

Commit ffa1cd3

Browse files
RalfJungbeamandala
authored andcommitted
stabilize duration_from_nanos_u128
1 parent a7de4cc commit ffa1cd3

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

library/core/src/time.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ impl Duration {
317317
/// # Examples
318318
///
319319
/// ```
320-
/// #![feature(duration_from_nanos_u128)]
321320
/// use std::time::Duration;
322321
///
323322
/// let nanos = 10_u128.pow(24) + 321;
@@ -326,12 +325,12 @@ impl Duration {
326325
/// assert_eq!(10_u64.pow(15), duration.as_secs());
327326
/// assert_eq!(321, duration.subsec_nanos());
328327
/// ```
329-
#[unstable(feature = "duration_from_nanos_u128", issue = "139201")]
330-
// This is necessary because of const `try_from`, but can be removed if a trait-free impl is used instead
331-
#[rustc_const_unstable(feature = "duration_from_nanos_u128", issue = "139201")]
328+
#[stable(feature = "duration_from_nanos_u128", since = "CURRENT_RUSTC_VERSION")]
329+
#[rustc_const_stable(feature = "duration_from_nanos_u128", since = "CURRENT_RUSTC_VERSION")]
332330
#[must_use]
333331
#[inline]
334332
#[track_caller]
333+
#[rustc_allow_const_fn_unstable(const_trait_impl, const_convert)] // for `u64::try_from`
335334
pub const fn from_nanos_u128(nanos: u128) -> Duration {
336335
const NANOS_PER_SEC: u128 = self::NANOS_PER_SEC as u128;
337336
let Ok(secs) = u64::try_from(nanos / NANOS_PER_SEC) else {

library/coretests/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#![feature(drop_guard)]
4343
#![feature(duration_constants)]
4444
#![feature(duration_constructors)]
45-
#![feature(duration_from_nanos_u128)]
4645
#![feature(error_generic_member_access)]
4746
#![feature(exact_div)]
4847
#![feature(exact_size_is_empty)]

src/tools/miri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![feature(derive_coerce_pointee)]
1818
#![feature(arbitrary_self_types)]
1919
#![feature(iter_advance_by)]
20-
#![feature(duration_from_nanos_u128)]
20+
#![cfg_attr(bootstrap, feature(duration_from_nanos_u128))]
2121
// Configure clippy and other lints
2222
#![allow(
2323
clippy::collapsible_else_if,

0 commit comments

Comments
 (0)