Uplift GenericArgKind, CanonicalVarValues, QueryInput

and make NestedGoals generic
This commit is contained in:
Michael Goulet 2024-05-15 22:37:42 -04:00
parent c00957a3e2
commit 05e0f8740a
25 changed files with 377 additions and 268 deletions

View file

@ -385,19 +385,31 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
a: Self,
b: Self,
) -> TypeTrace<'tcx> {
use GenericArgKind::*;
TypeTrace {
cause: cause.clone(),
values: match (a.unpack(), b.unpack()) {
(Lifetime(a), Lifetime(b)) => Regions(ExpectedFound::new(a_is_expected, a, b)),
(Type(a), Type(b)) => Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
(Const(a), Const(b)) => {
(GenericArgKind::Lifetime(a), GenericArgKind::Lifetime(b)) => {
Regions(ExpectedFound::new(a_is_expected, a, b))
}
(GenericArgKind::Type(a), GenericArgKind::Type(b)) => {
Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
}
(GenericArgKind::Const(a), GenericArgKind::Const(b)) => {
Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
}
(Lifetime(_), Type(_) | Const(_))
| (Type(_), Lifetime(_) | Const(_))
| (Const(_), Lifetime(_) | Type(_)) => {
(
GenericArgKind::Lifetime(_),
GenericArgKind::Type(_) | GenericArgKind::Const(_),
)
| (
GenericArgKind::Type(_),
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_),
)
| (
GenericArgKind::Const(_),
GenericArgKind::Lifetime(_) | GenericArgKind::Type(_),
) => {
bug!("relating different kinds: {a:?} {b:?}")
}
},

View file

@ -78,9 +78,9 @@ impl<T: Hash> Hash for Obligation<'_, T> {
}
}
impl<'tcx, P> From<Obligation<'tcx, P>> for ty::Goal<'tcx, P> {
impl<'tcx, P> From<Obligation<'tcx, P>> for solve::Goal<'tcx, P> {
fn from(value: Obligation<'tcx, P>) -> Self {
ty::Goal { param_env: value.param_env, predicate: value.predicate }
solve::Goal { param_env: value.param_env, predicate: value.predicate }
}
}