diff options
| author | Urgau <3616612+Urgau@users.noreply.github.com> | 2025-02-18 18:34:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-18 18:34:17 +0100 |
| commit | 61f04328db68eab599a64b120ba4d63b425df257 (patch) | |
| tree | b9496775b30322543f9df5c34a6517e0b5108896 | |
| parent | 73e5abd175767c2d536c8ad1818668c1f210f78b (diff) | |
| parent | f910684616f357a8084151a162ed3c3fe0e512e6 (diff) | |
| download | rust-61f04328db68eab599a64b120ba4d63b425df257.tar.gz rust-61f04328db68eab599a64b120ba4d63b425df257.zip | |
Rollup merge of #137211 - lcnr:alias-relate-accept-error, r=compiler-errors
don't ICE for alias-relate goals with error term see comment, fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/165 r? ``@compiler-errors``
| -rw-r--r-- | compiler/rustc_next_trait_solver/src/solve/alias_relate.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_type_ir/src/inherent.rs | 15 |
2 files changed, 26 insertions, 1 deletions
diff --git a/compiler/rustc_next_trait_solver/src/solve/alias_relate.rs b/compiler/rustc_next_trait_solver/src/solve/alias_relate.rs index d8c1dc8b4e9..0fc313e33b3 100644 --- a/compiler/rustc_next_trait_solver/src/solve/alias_relate.rs +++ b/compiler/rustc_next_trait_solver/src/solve/alias_relate.rs @@ -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() { diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index 6924216bd26..9277226b718 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -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(_))) } @@ -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 { @@ -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() { |
