Skip to content

Commit 3ccb1c3

Browse files
committed
Remove redundancy in cache key
1 parent f583513 commit 3ccb1c3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

compiler/rustc_infer/src/infer/combine.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ struct Generalizer<'cx, 'tcx> {
500500

501501
param_env: ty::ParamEnv<'tcx>,
502502

503-
cache: MiniMap<(Ty<'tcx>, Ty<'tcx>), RelateResult<'tcx, Ty<'tcx>>>,
503+
cache: MiniMap<Ty<'tcx>, RelateResult<'tcx, Ty<'tcx>>>,
504504
}
505505

506506
/// Result from a generalization operation. This includes
@@ -598,8 +598,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
598598
fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
599599
assert_eq!(t, t2); // we are abusing TypeRelation here; both LHS and RHS ought to be ==
600600

601-
let cache_key = (t, t2);
602-
if let Some(result) = self.cache.get(&cache_key) {
601+
if let Some(result) = self.cache.get(&t) {
603602
return result.clone();
604603
}
605604
debug!("generalize: t={:?}", t);
@@ -667,7 +666,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
667666
_ => relate::super_relate_tys(self, t, t),
668667
};
669668

670-
self.cache.insert(cache_key, result.clone());
669+
self.cache.insert(t, result.clone());
671670
return result;
672671
}
673672

compiler/rustc_middle/src/ty/print/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub trait Printer<'tcx>: Sized {
265265
/// type. It's just a heuristic so it makes some questionable
266266
/// decisions and we may want to adjust it later.
267267
///
268-
/// Visited set is needed in to avoid full iteration over
268+
/// Visited set is needed to avoid full iteration over
269269
/// deeply nested tuples that have no DefId.
270270
fn characteristic_def_id_of_type_cached<'a>(
271271
ty: Ty<'a>,

0 commit comments

Comments
 (0)