Use Term in ProjectionPredicate
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
This commit is contained in:
parent
fb57b7518d
commit
67f56671d0
51 changed files with 274 additions and 259 deletions
|
@ -377,7 +377,7 @@ impl GenericArgs<'_> {
|
|||
GenericArg::Type(ty) => matches!(ty.kind, TyKind::Err),
|
||||
_ => false,
|
||||
}) || self.bindings.iter().any(|arg| match arg.kind {
|
||||
TypeBindingKind::Equality { ty } => matches!(ty.kind, TyKind::Err),
|
||||
TypeBindingKind::Equality { term: Term::Ty(ty) } => matches!(ty.kind, TyKind::Err),
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
@ -2129,21 +2129,37 @@ pub struct TypeBinding<'hir> {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Debug, HashStable_Generic)]
|
||||
pub enum Term<'hir> {
|
||||
Ty(&'hir Ty<'hir>),
|
||||
Const(AnonConst),
|
||||
}
|
||||
|
||||
impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
|
||||
fn from(ty: &'hir Ty<'hir>) -> Self {
|
||||
Term::Ty(ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'hir> From<AnonConst> for Term<'hir> {
|
||||
fn from(c: AnonConst) -> Self {
|
||||
Term::Const(c)
|
||||
}
|
||||
}
|
||||
|
||||
// Represents the two kinds of type bindings.
|
||||
#[derive(Debug, HashStable_Generic)]
|
||||
pub enum TypeBindingKind<'hir> {
|
||||
/// E.g., `Foo<Bar: Send>`.
|
||||
Constraint { bounds: &'hir [GenericBound<'hir>] },
|
||||
/// E.g., `Foo<Bar = ()>`.
|
||||
Equality { ty: &'hir Ty<'hir> },
|
||||
/// E.g., `Foo<N = 3>`.
|
||||
Const { c: AnonConst },
|
||||
/// E.g., `Foo<Bar = ()>`, `Foo<Bar = ()>`
|
||||
Equality { term: Term<'hir> },
|
||||
}
|
||||
|
||||
impl TypeBinding<'_> {
|
||||
pub fn ty(&self) -> &Ty<'_> {
|
||||
match self.kind {
|
||||
TypeBindingKind::Equality { ref ty } => ty,
|
||||
TypeBindingKind::Equality { term: Term::Ty(ref ty) } => ty,
|
||||
_ => panic!("expected equality type binding for parenthesized generic args"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue