don't ICE for alias-relate goals with error term
This commit is contained in:
parent
273465e1f2
commit
f910684616
2 changed files with 26 additions and 1 deletions
|
@ -34,7 +34,17 @@ where
|
||||||
) -> QueryResult<I> {
|
) -> QueryResult<I> {
|
||||||
let cx = self.cx();
|
let cx = self.cx();
|
||||||
let Goal { param_env, predicate: (lhs, rhs, direction) } = goal;
|
let Goal { param_env, predicate: (lhs, rhs, direction) } = goal;
|
||||||
debug_assert!(lhs.to_alias_term().is_some() || rhs.to_alias_term().is_some());
|
|
||||||
|
// Check that the alias-relate goal is reasonable. Writeback for
|
||||||
|
// `coroutine_stalled_predicates` can replace alias terms with
|
||||||
|
// `{type error}` if the alias still contains infer vars, so we also
|
||||||
|
// accept alias-relate goals where one of the terms is an error.
|
||||||
|
debug_assert!(
|
||||||
|
lhs.to_alias_term().is_some()
|
||||||
|
|| rhs.to_alias_term().is_some()
|
||||||
|
|| lhs.is_error()
|
||||||
|
|| rhs.is_error()
|
||||||
|
);
|
||||||
|
|
||||||
// Structurally normalize the lhs.
|
// Structurally normalize the lhs.
|
||||||
let lhs = if let Some(alias) = lhs.to_alias_term() {
|
let lhs = if let Some(alias) = lhs.to_alias_term() {
|
||||||
|
|
|
@ -126,6 +126,10 @@ pub trait Ty<I: Interner<Ty = Self>>:
|
||||||
matches!(self.kind(), ty::Infer(ty::TyVar(_)))
|
matches!(self.kind(), ty::Infer(ty::TyVar(_)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_ty_error(self) -> bool {
|
||||||
|
matches!(self.kind(), ty::Error(_))
|
||||||
|
}
|
||||||
|
|
||||||
fn is_floating_point(self) -> bool {
|
fn is_floating_point(self) -> bool {
|
||||||
matches!(self.kind(), ty::Float(_) | ty::Infer(ty::FloatVar(_)))
|
matches!(self.kind(), ty::Float(_) | ty::Infer(ty::FloatVar(_)))
|
||||||
}
|
}
|
||||||
|
@ -284,6 +288,10 @@ pub trait Const<I: Interner<Const = Self>>:
|
||||||
fn is_ct_var(self) -> bool {
|
fn is_ct_var(self) -> bool {
|
||||||
matches!(self.kind(), ty::ConstKind::Infer(ty::InferConst::Var(_)))
|
matches!(self.kind(), ty::ConstKind::Infer(ty::InferConst::Var(_)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_ct_error(self) -> bool {
|
||||||
|
matches!(self.kind(), ty::ConstKind::Error(_))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ValueConst<I: Interner<ValueConst = Self>>: Copy + Debug + Hash + Eq {
|
pub trait ValueConst<I: Interner<ValueConst = Self>>: Copy + Debug + Hash + Eq {
|
||||||
|
@ -370,6 +378,13 @@ pub trait Term<I: Interner<Term = Self>>:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_error(self) -> bool {
|
||||||
|
match self.kind() {
|
||||||
|
ty::TermKind::Ty(ty) => ty.is_ty_error(),
|
||||||
|
ty::TermKind::Const(ct) => ct.is_ct_error(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn to_alias_term(self) -> Option<ty::AliasTerm<I>> {
|
fn to_alias_term(self) -> Option<ty::AliasTerm<I>> {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
ty::TermKind::Ty(ty) => match ty.kind() {
|
ty::TermKind::Ty(ty) => match ty.kind() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue