From a36c6361999ff23d604a5a0e7d06611ad31b6262 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 18 May 2021 07:48:00 -0400 Subject: [PATCH 1/2] Avoid cloning cache key --- compiler/rustc_data_structures/src/obligation_forest/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index 29d685ab530d6..74ceed67807a9 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -342,7 +342,7 @@ impl ObligationForest { return Ok(()); } - match self.active_cache.entry(cache_key.clone()) { + match self.active_cache.entry(cache_key) { Entry::Occupied(o) => { let node = &mut self.nodes[*o.get()]; if let Some(parent_index) = parent { @@ -366,7 +366,7 @@ impl ObligationForest { && self .error_cache .get(&obligation_tree_id) - .map(|errors| errors.contains(&cache_key)) + .map(|errors| errors.contains(v.key())) .unwrap_or(false); if already_failed { From 42b9d3fb723f33d903e1ef54a3f2439153b3a552 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 18 May 2021 10:37:42 -0400 Subject: [PATCH 2/2] Simplify `map | unwrap_or` to `map_or` --- compiler/rustc_data_structures/src/obligation_forest/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index 74ceed67807a9..d8f23aeabc10e 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -366,8 +366,7 @@ impl ObligationForest { && self .error_cache .get(&obligation_tree_id) - .map(|errors| errors.contains(v.key())) - .unwrap_or(false); + .map_or(false, |errors| errors.contains(v.key())); if already_failed { Err(())