1
Fork 0

Extract impl_subject_and_oglibations fn and make equate receive subjects

This commit is contained in:
Santiago Pastorino 2022-03-24 12:27:09 -03:00
parent 64df2ee1eb
commit 22b311bd82
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
4 changed files with 94 additions and 47 deletions

View file

@ -28,7 +28,7 @@
use super::*;
use rustc_middle::ty::relate::{Relate, TypeRelation};
use rustc_middle::ty::Const;
use rustc_middle::ty::{Const, ImplSubject};
pub struct At<'a, 'tcx> {
pub infcx: &'a InferCtxt<'a, 'tcx>,
@ -272,6 +272,29 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
}
}
impl<'tcx> ToTrace<'tcx> for ImplSubject<'tcx> {
fn to_trace(
tcx: TyCtxt<'tcx>,
cause: &ObligationCause<'tcx>,
a_is_expected: bool,
a: Self,
b: Self,
) -> TypeTrace<'tcx> {
match (a, b) {
(ImplSubject::Trait(trait_ref_a), ImplSubject::Trait(trait_ref_b)) => {
ToTrace::to_trace(tcx, cause, a_is_expected, trait_ref_a, trait_ref_b)
}
(ImplSubject::Inherent(ty_a), ImplSubject::Inherent(ty_b)) => {
ToTrace::to_trace(tcx, cause, a_is_expected, ty_a, ty_b)
}
(ImplSubject::Trait(_), ImplSubject::Inherent(_))
| (ImplSubject::Inherent(_), ImplSubject::Trait(_)) => {
bug!("can not trace TraitRef and Ty");
}
}
}
}
impl<'tcx> ToTrace<'tcx> for Ty<'tcx> {
fn to_trace(
_: TyCtxt<'tcx>,