File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -227,3 +227,18 @@ fn big_math() {
227
227
check ( instant. checked_add ( Duration :: from_secs ( 100 ) ) , Instant :: checked_sub) ;
228
228
check ( instant. checked_add ( Duration :: from_secs ( i64:: MAX as _ ) ) , Instant :: checked_sub) ;
229
229
}
230
+
231
+ #[ test]
232
+ #[ cfg( unix) ]
233
+ fn system_time_duration_since_max_range_on_unix ( ) {
234
+ // Repro regression https://github.com/rust-lang/rust/issues/146228
235
+
236
+ // Min and max values of `SystemTime` on Unix.
237
+ let min = SystemTime :: UNIX_EPOCH - ( Duration :: new ( i64:: MAX as u64 + 1 , 0 ) ) ;
238
+ let max = SystemTime :: UNIX_EPOCH + ( Duration :: new ( i64:: MAX as u64 , 999_999_999 ) ) ;
239
+
240
+ // This should succeed and not return a SystemTimeError due to incorrect comparison overflow
241
+ let delta = max. duration_since ( min) . expect ( "duration_since overflow" ) ;
242
+
243
+ assert_eq ! ( Duration :: MAX , delta) ;
244
+ }
You can’t perform that action at this time.
0 commit comments