diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_driver_impl/Cargo.toml | 2 | ||||
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_incremental/src/persist/fs.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 2 |
4 files changed, 10 insertions, 16 deletions
diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index ef577c03218..74da0d11e4b 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -49,7 +49,7 @@ rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_ty_utils = { path = "../rustc_ty_utils" } serde_json = "1.0.59" shlex = "1.0" -time = { version = "0.3.36", default-features = false, features = ["alloc", "formatting", "parsing", "macros"] } +time = { version = "0.3.36", default-features = false, features = ["alloc", "formatting", "macros"] } tracing = { version = "0.1.35" } # tidy-alphabetical-end diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 4362007d4ba..d2c4335cf2b 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -64,6 +64,7 @@ use rustc_span::source_map::FileLoader; use rustc_target::json::ToJson; use rustc_target::spec::{Target, TargetTuple}; use time::OffsetDateTime; +use time::macros::format_description; use tracing::trace; #[allow(unused_macros)] @@ -1356,8 +1357,7 @@ fn ice_path_with_config(config: Option<&UnstableOptions>) -> &'static Option<Pat let file_now = now .format( // Don't use a standard datetime format because Windows doesn't support `:` in paths - &time::format_description::parse("[year]-[month]-[day]T[hour]_[minute]_[second]") - .unwrap(), + &format_description!("[year]-[month]-[day]T[hour]_[minute]_[second]"), ) .unwrap_or_default(); let pid = std::process::id(); diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index 8769c4173c8..f6c3e8ebbcb 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -585,23 +585,17 @@ fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime fn timestamp_to_string(timestamp: SystemTime) -> BaseNString { let duration = timestamp.duration_since(UNIX_EPOCH).unwrap(); - let micros = duration.as_secs() * 1_000_000 + (duration.subsec_nanos() as u64) / 1000; + let micros: u64 = duration.as_micros().try_into().unwrap(); micros.to_base_fixed_len(CASE_INSENSITIVE) } fn string_to_timestamp(s: &str) -> Result<SystemTime, &'static str> { - let micros_since_unix_epoch = u64::from_str_radix(s, INT_ENCODE_BASE as u32); - - if micros_since_unix_epoch.is_err() { - return Err("timestamp not an int"); - } - - let micros_since_unix_epoch = micros_since_unix_epoch.unwrap(); + let micros_since_unix_epoch = match u64::from_str_radix(s, INT_ENCODE_BASE as u32) { + Ok(micros) => micros, + Err(_) => return Err("timestamp not an int"), + }; - let duration = Duration::new( - micros_since_unix_epoch / 1_000_000, - 1000 * (micros_since_unix_epoch % 1_000_000) as u32, - ); + let duration = Duration::from_micros(micros_since_unix_epoch); Ok(UNIX_EPOCH + duration) } diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 5e30f17d626..e7ed8288499 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -1098,7 +1098,7 @@ impl<D: Deps> CurrentDepGraph<D> { use std::time::{SystemTime, UNIX_EPOCH}; let duration = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); - let nanos = duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64; + let nanos = duration.as_nanos(); let mut stable_hasher = StableHasher::new(); nanos.hash(&mut stable_hasher); let anon_id_seed = stable_hasher.finish(); |
