File tree 2 files changed +7
-13
lines changed
rustc_incremental/src/persist
rustc_query_system/src/dep_graph
2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -585,23 +585,17 @@ fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime
585
585
586
586
fn timestamp_to_string ( timestamp : SystemTime ) -> BaseNString {
587
587
let duration = timestamp. duration_since ( UNIX_EPOCH ) . unwrap ( ) ;
588
- let micros = duration. as_secs ( ) * 1_000_000 + ( duration . subsec_nanos ( ) as u64 ) / 1000 ;
588
+ let micros: u64 = duration. as_micros ( ) . try_into ( ) . unwrap ( ) ;
589
589
micros. to_base_fixed_len ( CASE_INSENSITIVE )
590
590
}
591
591
592
592
fn string_to_timestamp ( s : & str ) -> Result < SystemTime , & ' static str > {
593
- let micros_since_unix_epoch = u64:: from_str_radix ( s, INT_ENCODE_BASE as u32 ) ;
594
-
595
- if micros_since_unix_epoch. is_err ( ) {
596
- return Err ( "timestamp not an int" ) ;
597
- }
598
-
599
- let micros_since_unix_epoch = micros_since_unix_epoch. unwrap ( ) ;
593
+ let micros_since_unix_epoch = match u64:: from_str_radix ( s, INT_ENCODE_BASE as u32 ) {
594
+ Ok ( micros) => micros,
595
+ Err ( _) => return Err ( "timestamp not an int" ) ,
596
+ } ;
600
597
601
- let duration = Duration :: new (
602
- micros_since_unix_epoch / 1_000_000 ,
603
- 1000 * ( micros_since_unix_epoch % 1_000_000 ) as u32 ,
604
- ) ;
598
+ let duration = Duration :: from_micros ( micros_since_unix_epoch) ;
605
599
Ok ( UNIX_EPOCH + duration)
606
600
}
607
601
Original file line number Diff line number Diff line change @@ -1098,7 +1098,7 @@ impl<D: Deps> CurrentDepGraph<D> {
1098
1098
use std:: time:: { SystemTime , UNIX_EPOCH } ;
1099
1099
1100
1100
let duration = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . unwrap ( ) ;
1101
- let nanos = duration. as_secs ( ) * 1_000_000_000 + duration . subsec_nanos ( ) as u64 ;
1101
+ let nanos = duration. as_nanos ( ) ;
1102
1102
let mut stable_hasher = StableHasher :: new ( ) ;
1103
1103
nanos. hash ( & mut stable_hasher) ;
1104
1104
let anon_id_seed = stable_hasher. finish ( ) ;
You can’t perform that action at this time.
0 commit comments