Include relation direction in AliasEq predicate
This commit is contained in:
parent
439292bc79
commit
5dc3fd7c05
16 changed files with 173 additions and 34 deletions
|
@ -288,7 +288,7 @@ impl FlagComputation {
|
|||
self.add_ty(ty);
|
||||
}
|
||||
ty::PredicateKind::Ambiguous => {}
|
||||
ty::PredicateKind::AliasEq(t1, t2) => {
|
||||
ty::PredicateKind::AliasEq(t1, t2, _) => {
|
||||
self.add_term(t1);
|
||||
self.add_term(t2);
|
||||
}
|
||||
|
|
|
@ -640,7 +640,25 @@ pub enum PredicateKind<'tcx> {
|
|||
/// This predicate requires two terms to be equal to eachother.
|
||||
///
|
||||
/// Only used for new solver
|
||||
AliasEq(Term<'tcx>, Term<'tcx>),
|
||||
AliasEq(Term<'tcx>, Term<'tcx>, AliasRelationDirection),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||
#[derive(HashStable, Debug)]
|
||||
pub enum AliasRelationDirection {
|
||||
Equate,
|
||||
Subtype,
|
||||
Supertype,
|
||||
}
|
||||
|
||||
impl AliasRelationDirection {
|
||||
pub fn invert(self) -> Self {
|
||||
match self {
|
||||
AliasRelationDirection::Equate => AliasRelationDirection::Equate,
|
||||
AliasRelationDirection::Subtype => AliasRelationDirection::Supertype,
|
||||
AliasRelationDirection::Supertype => AliasRelationDirection::Subtype,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The crate outlives map is computed during typeck and contains the
|
||||
|
@ -976,11 +994,11 @@ impl<'tcx> Term<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// This function returns `None` for `AliasKind::Opaque`.
|
||||
/// This function returns the inner `AliasTy` if this term is a projection.
|
||||
///
|
||||
/// FIXME: rename `AliasTy` to `AliasTerm` and make sure we correctly
|
||||
/// deal with constants.
|
||||
pub fn to_alias_term_no_opaque(&self, tcx: TyCtxt<'tcx>) -> Option<AliasTy<'tcx>> {
|
||||
pub fn to_projection_term(&self, tcx: TyCtxt<'tcx>) -> Option<AliasTy<'tcx>> {
|
||||
match self.unpack() {
|
||||
TermKind::Ty(ty) => match ty.kind() {
|
||||
ty::Alias(kind, alias_ty) => match kind {
|
||||
|
|
|
@ -2847,7 +2847,8 @@ define_print_and_forward_display! {
|
|||
p!("the type `", print(ty), "` is found in the environment")
|
||||
}
|
||||
ty::PredicateKind::Ambiguous => p!("ambiguous"),
|
||||
ty::PredicateKind::AliasEq(t1, t2) => p!(print(t1), " == ", print(t2)),
|
||||
// TODO
|
||||
ty::PredicateKind::AliasEq(t1, t2, _) => p!(print(t1), " == ", print(t2)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,8 @@ impl<'tcx> fmt::Debug for ty::PredicateKind<'tcx> {
|
|||
write!(f, "TypeWellFormedFromEnv({:?})", ty)
|
||||
}
|
||||
ty::PredicateKind::Ambiguous => write!(f, "Ambiguous"),
|
||||
ty::PredicateKind::AliasEq(t1, t2) => write!(f, "AliasEq({t1:?}, {t2:?})"),
|
||||
// TODO
|
||||
ty::PredicateKind::AliasEq(t1, t2, _) => write!(f, "AliasEq({t1:?}, {t2:?})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,6 +251,7 @@ TrivialTypeTraversalAndLiftImpls! {
|
|||
crate::ty::AssocItem,
|
||||
crate::ty::AssocKind,
|
||||
crate::ty::AliasKind,
|
||||
crate::ty::AliasRelationDirection,
|
||||
crate::ty::Placeholder<crate::ty::BoundRegionKind>,
|
||||
crate::ty::Placeholder<crate::ty::BoundTyKind>,
|
||||
crate::ty::ClosureKind,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue