Extract impl_subject_and_oglibations fn and make equate receive subjects
This commit is contained in:
parent
64df2ee1eb
commit
22b311bd82
4 changed files with 94 additions and 47 deletions
|
@ -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>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue