From 0cac8455e6f7587228458ef5607e8d3e6f71f347 Mon Sep 17 00:00:00 2001 From: Andrew Xie Date: Sun, 11 Jun 2023 22:45:04 -0400 Subject: [PATCH] Applied nits --- compiler/rustc_data_structures/src/unord.rs | 8 ++++---- compiler/rustc_incremental/src/persist/dirty_clean.rs | 10 ++++------ compiler/rustc_incremental/src/persist/fs.rs | 11 +++++------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index e18c7b415f6..2b21815b687 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -107,6 +107,10 @@ pub fn flat_map(self, f: F) -> UnordItems> { UnordItems(self.0.flat_map(f)) } + + pub fn collect>>(self) -> C { + self.into() + } } impl UnordItems> { @@ -161,10 +165,6 @@ pub fn into_sorted_stable_ord(self) -> Vec items.sort_by_cached_key(|x| x.to_stable_hash_key(hcx)); items } - - pub fn collect>>(self) -> C { - self.into() - } } /// This is a set collection type that tries very hard to not expose diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index cbe77e7b16d..f9cd01fd80d 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -198,7 +198,7 @@ fn assertion_auto(&mut self, item_id: LocalDefId, attr: &Attribute) -> Assertion 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.items().map(|x| x.as_str()).into_sorted_stable_ord() { + for e in except.items().into_sorted_stable_ord() { if !auto.remove(e) { self.tcx.sess.emit_fatal(errors::AssertionAuto { span: attr.span, name, e }); } @@ -377,17 +377,15 @@ fn check_item(&mut self, item_id: LocalDefId) { continue; }; self.checked_attrs.insert(attr.id); - for label in assertion.clean.items().map(|x| x.as_str()).into_sorted_stable_ord() { + for label in assertion.clean.items().into_sorted_stable_ord() { let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); self.assert_clean(item_span, dep_node); } - for label in assertion.dirty.items().map(|x| x.as_str()).into_sorted_stable_ord() { + for label in assertion.dirty.items().into_sorted_stable_ord() { let dep_node = DepNode::from_label_string(self.tcx, &label, def_path_hash).unwrap(); self.assert_dirty(item_span, dep_node); } - for label in - assertion.loaded_from_disk.items().map(|x| x.as_str()).into_sorted_stable_ord() - { + for label in assertion.loaded_from_disk.items().into_sorted_stable_ord() { 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 243057b99bc..7708deecec7 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -855,12 +855,11 @@ fn all_except_most_recent( let most_recent = deletion_candidates.items().map(|(&(timestamp, _), _)| timestamp).max(); if let Some(most_recent) = most_recent { - UnordMap::from( - deletion_candidates - .into_items() - .filter(|&((timestamp, _), _)| timestamp != most_recent) - .map(|((_, path), lock)| (path, lock)), - ) + deletion_candidates + .into_items() + .filter(|&((timestamp, _), _)| timestamp != most_recent) + .map(|((_, path), lock)| (path, lock)) + .collect() } else { UnordMap::default() }