Fixed failing test + minor cleanup
This commit is contained in:
parent
cf7dea5716
commit
96b577860d
@ -62,6 +62,11 @@ impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
|
|||||||
UnordItems(self.0.filter_map(f))
|
UnordItems(self.0.filter_map(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn for_each<F: Fn(T) -> ()>(self, f: F) {
|
||||||
|
self.0.for_each(|x| f(x));
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn max(self) -> Option<T>
|
pub fn max(self) -> Option<T>
|
||||||
where
|
where
|
||||||
|
@ -377,20 +377,17 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
self.checked_attrs.insert(attr.id);
|
self.checked_attrs.insert(attr.id);
|
||||||
assertion.clean.items().all(|label| {
|
assertion.clean.items().for_each(|label| {
|
||||||
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
|
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
|
||||||
self.assert_clean(item_span, dep_node);
|
self.assert_clean(item_span, dep_node);
|
||||||
true
|
|
||||||
});
|
});
|
||||||
assertion.dirty.items().all(|label| {
|
assertion.dirty.items().for_each(|label| {
|
||||||
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
|
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
|
||||||
self.assert_dirty(item_span, dep_node);
|
self.assert_dirty(item_span, dep_node);
|
||||||
true
|
|
||||||
});
|
});
|
||||||
assertion.loaded_from_disk.items().all(|label| {
|
assertion.loaded_from_disk.items().for_each(|label| {
|
||||||
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
|
let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap();
|
||||||
self.assert_loaded_from_disk(item_span, dep_node);
|
self.assert_loaded_from_disk(item_span, dep_node);
|
||||||
true
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -674,7 +674,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
|
|||||||
|
|
||||||
// Delete all lock files, that don't have an associated directory. They must
|
// Delete all lock files, that don't have an associated directory. They must
|
||||||
// be some kind of leftover
|
// be some kind of leftover
|
||||||
lock_file_to_session_dir.items().all(|(lock_file_name, directory_name)| {
|
lock_file_to_session_dir.items().for_each(|(lock_file_name, directory_name)| {
|
||||||
if directory_name.is_none() {
|
if directory_name.is_none() {
|
||||||
let Ok(timestamp) = extract_timestamp_from_session_dir(lock_file_name) else {
|
let Ok(timestamp) = extract_timestamp_from_session_dir(lock_file_name) else {
|
||||||
debug!(
|
debug!(
|
||||||
@ -682,7 +682,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
|
|||||||
crate_directory.join(&lock_file_name).display()
|
crate_directory.join(&lock_file_name).display()
|
||||||
);
|
);
|
||||||
// Ignore it
|
// Ignore it
|
||||||
return true;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let lock_file_path = crate_directory.join(&**lock_file_name);
|
let lock_file_path = crate_directory.join(&**lock_file_name);
|
||||||
@ -702,7 +702,6 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter out `None` directories
|
// Filter out `None` directories
|
||||||
|
@ -10,7 +10,7 @@ fn test_all_except_most_recent() {
|
|||||||
((UNIX_EPOCH + Duration::new(2, 0), PathBuf::from("2")), None),
|
((UNIX_EPOCH + Duration::new(2, 0), PathBuf::from("2")), None),
|
||||||
]);
|
]);
|
||||||
let mut paths = UnordSet::default();
|
let mut paths = UnordSet::default();
|
||||||
UnordSet::extend_unord(&mut paths, computed.into_items().map(|((_, path), _)| path));
|
paths.extend_unord(all_except_most_recent(computed).into_items().map(|(path, _)| path));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UnordSet::from(paths),
|
UnordSet::from(paths),
|
||||||
UnordSet::from_iter([
|
UnordSet::from_iter([
|
||||||
|
@ -163,7 +163,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
|
|||||||
Decodable::decode(&mut work_product_decoder);
|
Decodable::decode(&mut work_product_decoder);
|
||||||
|
|
||||||
for swp in work_products {
|
for swp in work_products {
|
||||||
let all_files_exist = swp.work_product.saved_files.iter().all(|(_, path)| {
|
let all_files_exist = swp.work_product.saved_files.items().all(|(_, path)| {
|
||||||
let exists = in_incr_comp_dir_sess(sess, path).exists();
|
let exists = in_incr_comp_dir_sess(sess, path).exists();
|
||||||
if !exists && sess.opts.unstable_opts.incremental_info {
|
if !exists && sess.opts.unstable_opts.incremental_info {
|
||||||
eprintln!("incremental: could not find file for work product: {path}",);
|
eprintln!("incremental: could not find file for work product: {path}",);
|
||||||
|
@ -105,7 +105,7 @@ pub fn save_work_product_index(
|
|||||||
if !new_work_products.contains_key(id) {
|
if !new_work_products.contains_key(id) {
|
||||||
work_product::delete_workproduct_files(sess, wp);
|
work_product::delete_workproduct_files(sess, wp);
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
!wp.saved_files.iter().all(|(_, path)| in_incr_comp_dir_sess(sess, path).exists())
|
!wp.saved_files.items().all(|(_, path)| in_incr_comp_dir_sess(sess, path).exists())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ pub fn save_work_product_index(
|
|||||||
// Check that we did not delete one of the current work-products:
|
// Check that we did not delete one of the current work-products:
|
||||||
debug_assert!({
|
debug_assert!({
|
||||||
new_work_products.iter().all(|(_, wp)| {
|
new_work_products.iter().all(|(_, wp)| {
|
||||||
wp.saved_files.iter().all(|(_, path)| in_incr_comp_dir_sess(sess, path).exists())
|
wp.saved_files.items().all(|(_, path)| in_incr_comp_dir_sess(sess, path).exists())
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use crate::persist::fs::*;
|
use crate::persist::fs::*;
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::unord::UnordMap;
|
||||||
use rustc_fs_util::link_or_copy;
|
use rustc_fs_util::link_or_copy;
|
||||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
@ -20,7 +20,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
|||||||
debug!(?cgu_name, ?files);
|
debug!(?cgu_name, ?files);
|
||||||
sess.opts.incremental.as_ref()?;
|
sess.opts.incremental.as_ref()?;
|
||||||
|
|
||||||
let mut saved_files = FxIndexMap::default();
|
let mut saved_files = UnordMap::default();
|
||||||
for (ext, path) in files {
|
for (ext, path) in files {
|
||||||
let file_name = format!("{cgu_name}.{ext}");
|
let file_name = format!("{cgu_name}.{ext}");
|
||||||
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
|
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
|
||||||
@ -46,10 +46,10 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
|||||||
|
|
||||||
/// Removes files for a given work product.
|
/// Removes files for a given work product.
|
||||||
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
|
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
|
||||||
for (_, path) in &work_product.saved_files {
|
work_product.saved_files.items().for_each(|(_, path)| {
|
||||||
let path = in_incr_comp_dir_sess(sess, path);
|
let path = in_incr_comp_dir_sess(sess, path);
|
||||||
if let Err(err) = std_fs::remove_file(&path) {
|
if let Err(err) = std_fs::remove_file(&path) {
|
||||||
sess.emit_warning(errors::DeleteWorkProduct { path: &path, err });
|
sess.emit_warning(errors::DeleteWorkProduct { path: &path, err });
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use rustc_data_structures::sharded::{self, Sharded};
|
|||||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||||
use rustc_data_structures::steal::Steal;
|
use rustc_data_structures::steal::Steal;
|
||||||
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
|
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
|
||||||
|
use rustc_data_structures::unord::UnordMap;
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
|
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
@ -1048,7 +1049,7 @@ pub struct WorkProduct {
|
|||||||
///
|
///
|
||||||
/// By convention, file extensions are currently used as identifiers, i.e. the key "o" maps to
|
/// By convention, file extensions are currently used as identifiers, i.e. the key "o" maps to
|
||||||
/// the object file's path, and "dwo" to the dwarf object file's path.
|
/// the object file's path, and "dwo" to the dwarf object file's path.
|
||||||
pub saved_files: FxIndexMap<String, String>,
|
pub saved_files: UnordMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index type for `DepNodeData`'s edges.
|
// Index type for `DepNodeData`'s edges.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user