@@ -26,13 +26,6 @@ pub(crate) enum Padding {
2626type Nanoseconds =
2727 RangedI32 < { -( Nanosecond . per ( Second ) as i32 - 1 ) } , { Nanosecond . per ( Second ) as i32 - 1 } > ;
2828
29- /// A value for the `nanoseconds` field that is exactly zero.
30- ///
31- /// This is used in a few locations, so centralizing the `unsafe` makes sense.
32- // Safety: Zero is in range.
33- #[ allow( clippy:: undocumented_unsafe_blocks) ] // rust-lang/rust-clippy#11246
34- const ZERO : Nanoseconds = unsafe { Nanoseconds :: new_unchecked ( 0 ) } ;
35-
3629/// A span of time with nanosecond precision.
3730///
3831/// Each `Duration` is composed of a whole number of seconds and a fractional part represented in
@@ -63,7 +56,7 @@ impl Default for Duration {
6356 fn default ( ) -> Self {
6457 Self {
6558 seconds : 0 ,
66- nanoseconds : ZERO ,
59+ nanoseconds : Nanoseconds :: new_static :: < 0 > ( ) ,
6760 padding : Padding :: Optimize ,
6861 }
6962 }
@@ -164,7 +157,7 @@ macro_rules! try_from_secs {
164157 // following numbers -128..=127. The check above (exp < 63)
165158 // doesn't cover i64::MIN as that is -2^63, so we have this
166159 // additional case to handle the asymmetry of iN::MIN.
167- break ' value Self :: new_ranged_unchecked( i64 :: MIN , ZERO ) ;
160+ break ' value Self :: new_ranged_unchecked( i64 :: MIN , Nanoseconds :: new_static :: < 0 > ( ) ) ;
168161 } else if $secs. is_nan( ) {
169162 // Change from std: std doesn't differentiate between the error
170163 // cases.
@@ -491,7 +484,7 @@ impl Duration {
491484 /// assert_eq!(Duration::seconds(1), 1_000.milliseconds());
492485 /// ```
493486 pub const fn seconds ( seconds : i64 ) -> Self {
494- Self :: new_ranged_unchecked ( seconds, ZERO )
487+ Self :: new_ranged_unchecked ( seconds, Nanoseconds :: new_static :: < 0 > ( ) )
495488 }
496489
497490 /// Creates a new `Duration` from the specified number of seconds represented as `f64`.
0 commit comments