diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /compiler/rustc_incremental/src/persist | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_incremental/src/persist')
-rw-r--r-- | compiler/rustc_incremental/src/persist/dirty_clean.rs | 2 | ||||
-rw-r--r-- | compiler/rustc_incremental/src/persist/fs.rs | 42 | ||||
-rw-r--r-- | compiler/rustc_incremental/src/persist/load.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_incremental/src/persist/save.rs | 8 |
4 files changed, 29 insertions, 27 deletions
diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index f9cd01fd8..5dd06c6ca 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -300,7 +300,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> { }, _ => self.tcx.sess.emit_fatal(errors::UndefinedCleanDirty { span: attr.span, - kind: format!("{:?}", node), + kind: format!("{node:?}"), }), }; let labels = diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index 7708deece..db8ea2bfe 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -427,13 +427,11 @@ fn copy_files(sess: &Session, target_dir: &Path, source_dir: &Path) -> Result<bo if sess.opts.unstable_opts.incremental_info { eprintln!( "[incremental] session directory: \ - {} files hard-linked", - files_linked + {files_linked} files hard-linked" ); eprintln!( "[incremental] session directory: \ - {} files copied", - files_copied + {files_copied} files copied" ); } @@ -540,9 +538,13 @@ where continue; } - let timestamp = extract_timestamp_from_session_dir(&directory_name).unwrap_or_else(|_| { - bug!("unexpected incr-comp session dir: {}", session_dir.display()) - }); + let timestamp = match extract_timestamp_from_session_dir(&directory_name) { + Ok(timestamp) => timestamp, + Err(e) => { + debug!("unexpected incr-comp session dir: {}: {}", session_dir.display(), e); + continue; + } + }; if timestamp > best_candidate.0 { best_candidate = (timestamp, Some(session_dir.clone())); @@ -564,14 +566,14 @@ fn is_session_directory_lock_file(file_name: &str) -> bool { file_name.starts_with("s-") && file_name.ends_with(LOCK_FILE_EXT) } -fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime, ()> { +fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime, &'static str> { if !is_session_directory(directory_name) { - return Err(()); + return Err("not a directory"); } let dash_indices: Vec<_> = directory_name.match_indices('-').map(|(idx, _)| idx).collect(); if dash_indices.len() != 3 { - return Err(()); + return Err("not three dashes in name"); } string_to_timestamp(&directory_name[dash_indices[0] + 1..dash_indices[1]]) @@ -583,11 +585,11 @@ fn timestamp_to_string(timestamp: SystemTime) -> String { base_n::encode(micros as u128, INT_ENCODE_BASE) } -fn string_to_timestamp(s: &str) -> Result<SystemTime, ()> { +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(()); + return Err("timestamp not an int"); } let micros_since_unix_epoch = micros_since_unix_epoch.unwrap(); @@ -604,7 +606,7 @@ fn crate_path(sess: &Session, crate_name: Symbol, stable_crate_id: StableCrateId let stable_crate_id = base_n::encode(stable_crate_id.as_u64() as u128, INT_ENCODE_BASE); - let crate_name = format!("{}-{}", crate_name, stable_crate_id); + let crate_name = format!("{crate_name}-{stable_crate_id}"); incr_dir.join(crate_name) } @@ -730,13 +732,13 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { debug!("garbage_collect_session_directories() - inspecting: {}", directory_name); let Ok(timestamp) = extract_timestamp_from_session_dir(directory_name) else { - debug!( - "found session-dir with malformed timestamp: {}", - crate_directory.join(directory_name).display() - ); - // Ignore it - return None; - }; + debug!( + "found session-dir with malformed timestamp: {}", + crate_directory.join(directory_name).display() + ); + // Ignore it + return None; + }; if is_finalized(directory_name) { let lock_file_path = crate_directory.join(lock_file_name); diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index bb479b5bd..8d67f6925 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -3,7 +3,7 @@ use crate::errors; use rustc_data_structures::memmap::Mmap; use rustc_data_structures::unord::UnordMap; -use rustc_middle::dep_graph::{SerializedDepGraph, WorkProduct, WorkProductId}; +use rustc_middle::dep_graph::{SerializedDepGraph, WorkProductMap}; use rustc_middle::query::on_disk_cache::OnDiskCache; use rustc_serialize::opaque::MemDecoder; use rustc_serialize::Decodable; @@ -16,8 +16,6 @@ use super::file_format; use super::fs::*; use super::work_product; -type WorkProductMap = UnordMap<WorkProductId, WorkProduct>; - #[derive(Debug)] /// Represents the result of an attempt to load incremental compilation data. pub enum LoadResult<T> { diff --git a/compiler/rustc_incremental/src/persist/save.rs b/compiler/rustc_incremental/src/persist/save.rs index bfaa52f9c..0cfaf5837 100644 --- a/compiler/rustc_incremental/src/persist/save.rs +++ b/compiler/rustc_incremental/src/persist/save.rs @@ -1,7 +1,9 @@ use crate::errors; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync::join; -use rustc_middle::dep_graph::{DepGraph, SerializedDepGraph, WorkProduct, WorkProductId}; +use rustc_middle::dep_graph::{ + DepGraph, SerializedDepGraph, WorkProduct, WorkProductId, WorkProductMap, +}; use rustc_middle::ty::TyCtxt; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; use rustc_serialize::Encodable as RustcEncodable; @@ -101,7 +103,7 @@ pub fn save_work_product_index( // deleted during invalidation. Some object files don't change their // content, they are just not needed anymore. let previous_work_products = dep_graph.previous_work_products(); - for (id, wp) in previous_work_products.iter() { + for (id, wp) in previous_work_products.to_sorted_stable_ord().iter() { if !new_work_products.contains_key(id) { work_product::delete_workproduct_files(sess, wp); debug_assert!( @@ -146,7 +148,7 @@ fn encode_query_cache(tcx: TyCtxt<'_>, encoder: FileEncoder) -> FileEncodeResult pub fn build_dep_graph( sess: &Session, prev_graph: SerializedDepGraph, - prev_work_products: FxIndexMap<WorkProductId, WorkProduct>, + prev_work_products: WorkProductMap, ) -> Option<DepGraph> { if sess.opts.incremental.is_none() { // No incremental compilation. |