From 3ccb1c37e6f37070b090b63acb3751438c152ed4 Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Fri, 18 Sep 2020 06:07:19 +0000 Subject: [PATCH] Remove redundancy in cache key --- compiler/rustc_infer/src/infer/combine.rs | 7 +++---- compiler/rustc_middle/src/ty/print/mod.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index 68197f75b9f..5bd6c667fd7 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -500,7 +500,7 @@ struct Generalizer<'cx, 'tcx> { param_env: ty::ParamEnv<'tcx>, - cache: MiniMap<(Ty<'tcx>, Ty<'tcx>), RelateResult<'tcx, Ty<'tcx>>>, + cache: MiniMap, RelateResult<'tcx, Ty<'tcx>>>, } /// Result from a generalization operation. This includes @@ -598,8 +598,7 @@ fn relate_with_variance>( fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { assert_eq!(t, t2); // we are abusing TypeRelation here; both LHS and RHS ought to be == - let cache_key = (t, t2); - if let Some(result) = self.cache.get(&cache_key) { + if let Some(result) = self.cache.get(&t) { return result.clone(); } debug!("generalize: t={:?}", t); @@ -667,7 +666,7 @@ fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { _ => relate::super_relate_tys(self, t, t), }; - self.cache.insert(cache_key, result.clone()); + self.cache.insert(t, result.clone()); return result; } diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 4e424156c4d..f315292dab5 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -265,7 +265,7 @@ fn default_print_impl_path( /// type. It's just a heuristic so it makes some questionable /// decisions and we may want to adjust it later. /// -/// Visited set is needed in to avoid full iteration over +/// Visited set is needed to avoid full iteration over /// deeply nested tuples that have no DefId. fn characteristic_def_id_of_type_cached<'a>( ty: Ty<'a>,