1
Fork 0

CollectAllMismatches relation should respect int/float infer vars

This commit is contained in:
Michael Goulet 2022-12-21 05:42:48 +00:00
parent 978dd2e3b8
commit c6ef53477e

View file

@ -14,21 +14,27 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
fn tag(&self) -> &'static str { fn tag(&self) -> &'static str {
"CollectAllMismatches" "CollectAllMismatches"
} }
fn tcx(&self) -> TyCtxt<'tcx> { fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx self.infcx.tcx
} }
fn intercrate(&self) -> bool { fn intercrate(&self) -> bool {
false false
} }
fn param_env(&self) -> ty::ParamEnv<'tcx> { fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env self.param_env
} }
fn a_is_expected(&self) -> bool { fn a_is_expected(&self) -> bool {
true true
} // irrelevant }
fn mark_ambiguous(&mut self) { fn mark_ambiguous(&mut self) {
bug!() bug!()
} }
fn relate_with_variance<T: Relate<'tcx>>( fn relate_with_variance<T: Relate<'tcx>>(
&mut self, &mut self,
_: ty::Variance, _: ty::Variance,
@ -38,6 +44,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
) -> RelateResult<'tcx, T> { ) -> RelateResult<'tcx, T> {
self.relate(a, b) self.relate(a, b)
} }
fn regions( fn regions(
&mut self, &mut self,
a: ty::Region<'tcx>, a: ty::Region<'tcx>,
@ -45,15 +52,20 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
) -> RelateResult<'tcx, ty::Region<'tcx>> { ) -> RelateResult<'tcx, ty::Region<'tcx>> {
Ok(a) Ok(a)
} }
fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
if a == b || matches!(a.kind(), ty::Infer(_)) || matches!(b.kind(), ty::Infer(_)) { self.infcx.probe(|_| {
return Ok(a); if a.is_ty_infer() || b.is_ty_infer() {
} Ok(a)
relate::super_relate_tys(self, a, b).or_else(|e| { } else {
self.infcx.super_combine_tys(self, a, b).or_else(|e| {
self.errors.push(e); self.errors.push(e);
Ok(a) Ok(a)
}) })
} }
})
}
fn consts( fn consts(
&mut self, &mut self,
a: ty::Const<'tcx>, a: ty::Const<'tcx>,
@ -64,6 +76,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
} }
relate::super_relate_consts(self, a, b) // could do something similar here for constants! relate::super_relate_consts(self, a, b) // could do something similar here for constants!
} }
fn binders<T: Relate<'tcx>>( fn binders<T: Relate<'tcx>>(
&mut self, &mut self,
a: ty::Binder<'tcx, T>, a: ty::Binder<'tcx, T>,