Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/alias_relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ where
) -> QueryResult<I> {
let cx = self.cx();
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.
let lhs = if let Some(alias) = lhs.to_alias_term() {
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_type_ir/src/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ pub trait Ty<I: Interner<Ty = Self>>:
matches!(self.kind(), ty::Infer(ty::TyVar(_)))
}

fn is_ty_error(self) -> bool {
matches!(self.kind(), ty::Error(_))
}

fn is_floating_point(self) -> bool {
matches!(self.kind(), ty::Float(_) | ty::Infer(ty::FloatVar(_)))
}
Expand Down Expand Up @@ -284,6 +288,10 @@ pub trait Const<I: Interner<Const = Self>>:
fn is_ct_var(self) -> bool {
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 {
Expand Down Expand Up @@ -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>> {
match self.kind() {
ty::TermKind::Ty(ty) => match ty.kind() {
Expand Down
Loading