diff options
| author | Andrew Xie <ndrew.xie@gmail.com> | 2023-06-05 00:16:20 -0400 |
|---|---|---|
| committer | Andrew Xie <ndrew.xie@gmail.com> | 2023-06-05 00:16:20 -0400 |
| commit | f5f638c12434e3c277fde8f4245273c2cc3c8110 (patch) | |
| tree | ca122dc6e3c724608f0dd2194b42226d0b054738 /compiler/rustc_incremental/src | |
| parent | 6f2d3dee1790f8066394d1198fd1864b5fae45a3 (diff) | |
| download | rust-f5f638c12434e3c277fde8f4245273c2cc3c8110.tar.gz rust-f5f638c12434e3c277fde8f4245273c2cc3c8110.zip | |
Fixed to_sorted => to_sorted_stable_ord
Diffstat (limited to 'compiler/rustc_incremental/src')
5 files changed, 49 insertions, 37 deletions
diff --git a/compiler/rustc_incremental/src/assert_module_sources.rs b/compiler/rustc_incremental/src/assert_module_sources.rs index 3e12c9b5016..3d9b1c2e741 100644 --- a/compiler/rustc_incremental/src/assert_module_sources.rs +++ b/compiler/rustc_incremental/src/assert_module_sources.rs @@ -118,8 +118,8 @@ impl<'tcx> AssertModuleSource<'tcx> { debug!("mapping '{}' to cgu name '{}'", self.field(attr, sym::module), cgu_name); if !self.available_cgus.contains(&cgu_name) { - let cgu_names: Vec<String> = - self.available_cgus.items().map(|cgu| cgu.as_str().to_owned()).into_sorted(&()); + let cgu_names: Vec<&str> = + self.available_cgus.items().map(|cgu| cgu.as_str()).into_sorted_stable_ord(true); self.tcx.sess.emit_err(errors::NoModuleNamed { span: attr.span, user_path, diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index 6381a05dfdc..786a0e0d3b2 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -198,7 +198,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> { let (name, mut auto) = self.auto_labels(item_id, attr); let except = self.except(attr); let loaded_from_disk = self.loaded_from_disk(attr); - for e in except.to_sorted(&(), false) { + for e in except.items().map(|x| x.as_str()).into_sorted_stable_ord(false) { if !auto.remove(e) { self.tcx.sess.emit_fatal(errors::AssertionAuto { span: attr.span, name, e }); } @@ -377,18 +377,20 @@ impl<'tcx> DirtyCleanVisitor<'tcx> { continue; }; self.checked_attrs.insert(attr.id); - assertion.clean.to_sorted(&(), false).iter().for_each(|label| { + for label in assertion.clean.items().map(|x| x.as_str()).into_sorted_stable_ord(false) { let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); self.assert_clean(item_span, dep_node); - }); - assertion.dirty.to_sorted(&(), false).iter().for_each(|label| { + } + for label in assertion.dirty.items().map(|x| x.as_str()).into_sorted_stable_ord(false) { let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); self.assert_dirty(item_span, dep_node); - }); - assertion.loaded_from_disk.to_sorted(&(), false).iter().for_each(|label| { + } + for label in + assertion.loaded_from_disk.items().map(|x| x.as_str()).into_sorted_stable_ord(false) + { let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); self.assert_loaded_from_disk(item_span, dep_node); - }); + } } } } diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index f0e5f07230f..550772a6881 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -661,8 +661,9 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { session_directories.sort(); // Now map from lock files to session directories - let lock_file_to_session_dir: UnordMap<String, Option<String>> = - UnordMap::from(lock_files.into_items().map(|lock_file_name| { + let lock_file_to_session_dir: UnordMap<String, Option<String>> = lock_files + .into_items() + .map(|lock_file_name| { assert!(lock_file_name.ends_with(LOCK_FILE_EXT)); let dir_prefix_end = lock_file_name.len() - LOCK_FILE_EXT.len(); let session_dir = { @@ -670,41 +671,45 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { session_directories.iter().find(|dir_name| dir_name.starts_with(dir_prefix)) }; (lock_file_name, session_dir.map(String::clone)) - })); + }) + .into(); // Delete all lock files, that don't have an associated directory. They must // be some kind of leftover - lock_file_to_session_dir.to_sorted(&(), false).iter().for_each( - |(lock_file_name, directory_name)| { - if directory_name.is_none() { - let Ok(timestamp) = extract_timestamp_from_session_dir(lock_file_name) else { + let lock_file_to_session_dir_iter = lock_file_to_session_dir + .items() + .map(|(file, dir)| (file.as_str(), dir.as_ref().map(|y| y.as_str()))); + for (lock_file_name, directory_name) in + lock_file_to_session_dir_iter.into_sorted_stable_ord(false) + { + if directory_name.is_none() { + let Ok(timestamp) = extract_timestamp_from_session_dir(lock_file_name) else { debug!( "found lock-file with malformed timestamp: {}", crate_directory.join(&lock_file_name).display() ); // Ignore it - return; + continue; }; - let lock_file_path = crate_directory.join(&**lock_file_name); + let lock_file_path = crate_directory.join(&*lock_file_name); - if is_old_enough_to_be_collected(timestamp) { - debug!( - "garbage_collect_session_directories() - deleting \ - garbage lock file: {}", - lock_file_path.display() - ); - delete_session_dir_lock_file(sess, &lock_file_path); - } else { - debug!( - "garbage_collect_session_directories() - lock file with \ - no session dir not old enough to be collected: {}", - lock_file_path.display() - ); - } + if is_old_enough_to_be_collected(timestamp) { + debug!( + "garbage_collect_session_directories() - deleting \ + garbage lock file: {}", + lock_file_path.display() + ); + delete_session_dir_lock_file(sess, &lock_file_path); + } else { + debug!( + "garbage_collect_session_directories() - lock file with \ + no session dir not old enough to be collected: {}", + lock_file_path.display() + ); } - }, - ); + } + } // Filter out `None` directories let lock_file_to_session_dir: UnordMap<String, String> = diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index 0727523a229..bb479b5bdcc 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -147,7 +147,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture { let report_incremental_info = sess.opts.unstable_opts.incremental_info; let expected_hash = sess.opts.dep_tracking_hash(false); - let mut prev_work_products = FxIndexMap::default(); + let mut prev_work_products = UnordMap::default(); // If we are only building with -Zquery-dep-graph but without an actual // incr. comp. session directory, we skip this. Otherwise we'd fail diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs index b0d173ab304..ae604b2ca0b 100644 --- a/compiler/rustc_incremental/src/persist/work_product.rs +++ b/compiler/rustc_incremental/src/persist/work_product.rs @@ -46,10 +46,15 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir( /// Removes files for a given work product. pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) { - work_product.saved_files.to_sorted(&(), false).iter().for_each(|(_, path)| { + for path in work_product + .saved_files + .items() + .map(|(_, path)| path.as_str()) + .into_sorted_stable_ord(false) + { let path = in_incr_comp_dir_sess(sess, path); if let Err(err) = std_fs::remove_file(&path) { sess.emit_warning(errors::DeleteWorkProduct { path: &path, err }); } - }); + } } |
