Avoid no-op unlink+link dances in incr comp
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
//! [work products]: WorkProduct
|
||||
|
||||
use std::fs as std_fs;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_fs_util::link_or_copy;
|
||||
@@ -20,6 +20,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
||||
sess: &Session,
|
||||
cgu_name: &str,
|
||||
files: &[(&'static str, &Path)],
|
||||
known_links: &[PathBuf],
|
||||
) -> Option<(WorkProductId, WorkProduct)> {
|
||||
debug!(?cgu_name, ?files);
|
||||
sess.opts.incremental.as_ref()?;
|
||||
@@ -28,6 +29,10 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
||||
for (ext, path) in files {
|
||||
let file_name = format!("{cgu_name}.{ext}");
|
||||
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
|
||||
if known_links.contains(&path_in_incr_dir) {
|
||||
let _ = saved_files.insert(ext.to_string(), file_name);
|
||||
continue;
|
||||
}
|
||||
match link_or_copy(path, &path_in_incr_dir) {
|
||||
Ok(_) => {
|
||||
let _ = saved_files.insert(ext.to_string(), file_name);
|
||||
|
||||
Reference in New Issue
Block a user