Skip to content

Commit 955effb

Browse files
authored
Unrolled build for rust-lang#137211
Rollup merge of rust-lang#137211 - lcnr:alias-relate-accept-error, r=compiler-errors don't ICE for alias-relate goals with error term see comment, fixes rust-lang/trait-system-refactor-initiative#165 r? ``@compiler-errors``
2 parents 3b022d8 + f910684 commit 955effb

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

compiler/rustc_next_trait_solver/src/solve/alias_relate.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ where
3434
) -> QueryResult<I> {
3535
let cx = self.cx();
3636
let Goal { param_env, predicate: (lhs, rhs, direction) } = goal;
37-
debug_assert!(lhs.to_alias_term().is_some() || rhs.to_alias_term().is_some());
37+
38+
// Check that the alias-relate goal is reasonable. Writeback for
39+
// `coroutine_stalled_predicates` can replace alias terms with
40+
// `{type error}` if the alias still contains infer vars, so we also
41+
// accept alias-relate goals where one of the terms is an error.
42+
debug_assert!(
43+
lhs.to_alias_term().is_some()
44+
|| rhs.to_alias_term().is_some()
45+
|| lhs.is_error()
46+
|| rhs.is_error()
47+
);
3848

3949
// Structurally normalize the lhs.
4050
let lhs = if let Some(alias) = lhs.to_alias_term() {

compiler/rustc_type_ir/src/inherent.rs

+15
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ pub trait Ty<I: Interner<Ty = Self>>:
126126
matches!(self.kind(), ty::Infer(ty::TyVar(_)))
127127
}
128128

129+
fn is_ty_error(self) -> bool {
130+
matches!(self.kind(), ty::Error(_))
131+
}
132+
129133
fn is_floating_point(self) -> bool {
130134
matches!(self.kind(), ty::Float(_) | ty::Infer(ty::FloatVar(_)))
131135
}
@@ -284,6 +288,10 @@ pub trait Const<I: Interner<Const = Self>>:
284288
fn is_ct_var(self) -> bool {
285289
matches!(self.kind(), ty::ConstKind::Infer(ty::InferConst::Var(_)))
286290
}
291+
292+
fn is_ct_error(self) -> bool {
293+
matches!(self.kind(), ty::ConstKind::Error(_))
294+
}
287295
}
288296

289297
pub trait ValueConst<I: Interner<ValueConst = Self>>: Copy + Debug + Hash + Eq {
@@ -370,6 +378,13 @@ pub trait Term<I: Interner<Term = Self>>:
370378
}
371379
}
372380

381+
fn is_error(self) -> bool {
382+
match self.kind() {
383+
ty::TermKind::Ty(ty) => ty.is_ty_error(),
384+
ty::TermKind::Const(ct) => ct.is_ct_error(),
385+
}
386+
}
387+
373388
fn to_alias_term(self) -> Option<ty::AliasTerm<I>> {
374389
match self.kind() {
375390
ty::TermKind::Ty(ty) => match ty.kind() {

0 commit comments

Comments
 (0)