Skip to content

Commit 060f3e0

Browse files
committed
generalize: no need to cache errors
1 parent 44adfcc commit 060f3e0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/rustc_infer/src/infer/combine.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ struct Generalizer<'cx, 'tcx> {
486486

487487
param_env: ty::ParamEnv<'tcx>,
488488

489-
cache: SsoHashMap<Ty<'tcx>, RelateResult<'tcx, Ty<'tcx>>>,
489+
cache: SsoHashMap<Ty<'tcx>, Ty<'tcx>>,
490490
}
491491

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

596-
if let Some(result) = self.cache.get(&t) {
597-
return result.clone();
596+
if let Some(&result) = self.cache.get(&t) {
597+
return Ok(result);
598598
}
599599
debug!("generalize: t={:?}", t);
600600

@@ -664,10 +664,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
664664
Ok(t)
665665
}
666666
_ => relate::super_relate_tys(self, t, t),
667-
};
667+
}?;
668668

669-
self.cache.insert(t, result.clone());
670-
return result;
669+
self.cache.insert(t, result);
670+
Ok(result)
671671
}
672672

673673
fn regions(

0 commit comments

Comments
 (0)