@@ -38,18 +38,15 @@ impl SystemTime {
3838 SystemTime { t : Timespec :: now ( libc:: CLOCK_REALTIME ) }
3939 }
4040
41- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
42- pub const fn sub_time ( & self , other : & SystemTime ) -> Result < Duration , Duration > {
41+ pub fn sub_time ( & self , other : & SystemTime ) -> Result < Duration , Duration > {
4342 self . t . sub_timespec ( & other. t )
4443 }
4544
46- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
47- pub const fn checked_add_duration ( & self , other : & Duration ) -> Option < SystemTime > {
45+ pub fn checked_add_duration ( & self , other : & Duration ) -> Option < SystemTime > {
4846 Some ( SystemTime { t : self . t . checked_add_duration ( other) ? } )
4947 }
5048
51- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
52- pub const fn checked_sub_duration ( & self , other : & Duration ) -> Option < SystemTime > {
49+ pub fn checked_sub_duration ( & self , other : & Duration ) -> Option < SystemTime > {
5350 Some ( SystemTime { t : self . t . checked_sub_duration ( other) ? } )
5451 }
5552}
@@ -136,15 +133,8 @@ impl Timespec {
136133 Timespec :: new ( t. tv_sec as i64 , t. tv_nsec as i64 ) . unwrap ( )
137134 }
138135
139- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
140- pub const fn sub_timespec ( & self , other : & Timespec ) -> Result < Duration , Duration > {
141- // FIXME: const PartialOrd
142- let mut cmp = self . tv_sec - other. tv_sec ;
143- if cmp == 0 {
144- cmp = self . tv_nsec . as_inner ( ) as i64 - other. tv_nsec . as_inner ( ) as i64 ;
145- }
146-
147- if cmp >= 0 {
136+ pub fn sub_timespec ( & self , other : & Timespec ) -> Result < Duration , Duration > {
137+ if self >= other {
148138 // NOTE(eddyb) two aspects of this `if`-`else` are required for LLVM
149139 // to optimize it into a branchless form (see also #75545):
150140 //
@@ -179,8 +169,7 @@ impl Timespec {
179169 }
180170 }
181171
182- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
183- pub const fn checked_add_duration ( & self , other : & Duration ) -> Option < Timespec > {
172+ pub fn checked_add_duration ( & self , other : & Duration ) -> Option < Timespec > {
184173 let mut secs = self . tv_sec . checked_add_unsigned ( other. as_secs ( ) ) ?;
185174
186175 // Nano calculations can't overflow because nanos are <1B which fit
@@ -190,11 +179,10 @@ impl Timespec {
190179 nsec -= NSEC_PER_SEC as u32 ;
191180 secs = secs. checked_add ( 1 ) ?;
192181 }
193- Some ( unsafe { Timespec :: new_unchecked ( secs, nsec as i64 ) } )
182+ Some ( unsafe { Timespec :: new_unchecked ( secs, nsec. into ( ) ) } )
194183 }
195184
196- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
197- pub const fn checked_sub_duration ( & self , other : & Duration ) -> Option < Timespec > {
185+ pub fn checked_sub_duration ( & self , other : & Duration ) -> Option < Timespec > {
198186 let mut secs = self . tv_sec . checked_sub_unsigned ( other. as_secs ( ) ) ?;
199187
200188 // Similar to above, nanos can't overflow.
@@ -203,7 +191,7 @@ impl Timespec {
203191 nsec += NSEC_PER_SEC as i32 ;
204192 secs = secs. checked_sub ( 1 ) ?;
205193 }
206- Some ( unsafe { Timespec :: new_unchecked ( secs, nsec as i64 ) } )
194+ Some ( unsafe { Timespec :: new_unchecked ( secs, nsec. into ( ) ) } )
207195 }
208196
209197 #[ allow( dead_code) ]
0 commit comments