1
Fork 0

generalize: no need to cache errors

This commit is contained in:
lcnr 2022-07-04 15:35:21 +02:00
parent 44adfccffe
commit 060f3e0c65

View file

@ -486,7 +486,7 @@ struct Generalizer<'cx, 'tcx> {
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
cache: SsoHashMap<Ty<'tcx>, RelateResult<'tcx, Ty<'tcx>>>, cache: SsoHashMap<Ty<'tcx>, Ty<'tcx>>,
} }
/// Result from a generalization operation. This includes /// Result from a generalization operation. This includes
@ -593,8 +593,8 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { 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 == assert_eq!(t, t2); // we are abusing TypeRelation here; both LHS and RHS ought to be ==
if let Some(result) = self.cache.get(&t) { if let Some(&result) = self.cache.get(&t) {
return result.clone(); return Ok(result);
} }
debug!("generalize: t={:?}", t); debug!("generalize: t={:?}", t);
@ -664,10 +664,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
Ok(t) Ok(t)
} }
_ => relate::super_relate_tys(self, t, t), _ => relate::super_relate_tys(self, t, t),
}; }?;
self.cache.insert(t, result.clone()); self.cache.insert(t, result);
return result; Ok(result)
} }
fn regions( fn regions(