fixup let-else on typing mode in the compiler

This commit is contained in:
Jana Dönszelmann
2026-04-14 10:59:42 +02:00
parent 778d27441d
commit 26a0fdcdcd
3 changed files with 23 additions and 8 deletions
+10 -3
View File
@@ -673,9 +673,16 @@ pub(crate) fn drain_stalled_coroutine_obligations(&self) {
// being stalled on a coroutine.
self.select_obligations_where_possible(|_| {});
let ty::TypingMode::Analysis { defining_opaque_types_and_generators } = self.typing_mode()
else {
bug!();
let defining_opaque_types_and_generators = match self.typing_mode() {
ty::TypingMode::Analysis { defining_opaque_types_and_generators } => {
defining_opaque_types_and_generators
}
ty::TypingMode::Coherence
| ty::TypingMode::Borrowck { .. }
| ty::TypingMode::PostBorrowckAnalysis { .. }
| ty::TypingMode::PostAnalysis => {
bug!()
}
};
if defining_opaque_types_and_generators
+12 -4
View File
@@ -1,8 +1,9 @@
use rustc_hir::def::DefKind;
use rustc_infer::traits::ObligationCause;
use rustc_middle::bug;
use rustc_middle::ty::{
self, DefiningScopeKind, DefinitionSiteHiddenType, OpaqueTypeKey, ProvisionalHiddenType,
TypeVisitableExt, TypingMode,
TypeVisitableExt,
};
use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
use rustc_trait_selection::opaque_types::{
@@ -97,9 +98,16 @@ fn compute_definition_site_hidden_types(
debug!(?opaque_types);
let tcx = self.tcx;
let TypingMode::Analysis { defining_opaque_types_and_generators } = self.typing_mode()
else {
unreachable!();
let defining_opaque_types_and_generators = match self.typing_mode() {
ty::TypingMode::Analysis { defining_opaque_types_and_generators } => {
defining_opaque_types_and_generators
}
ty::TypingMode::Coherence
| ty::TypingMode::Borrowck { .. }
| ty::TypingMode::PostBorrowckAnalysis { .. }
| ty::TypingMode::PostAnalysis => {
bug!()
}
};
for def_id in defining_opaque_types_and_generators {
@@ -442,7 +442,7 @@ pub(super) fn assemble_and_evaluate_candidates<G: GoalKind<D>>(
// normalizing the self type as well, since type variables are not uniquified.
let goal = self.resolve_vars_if_possible(goal);
if let TypingMode::Coherence = self.typing_mode()
if self.typing_mode().is_coherence()
&& let Ok(candidate) = self.consider_coherence_unknowable_candidate(goal)
{
candidates.push(candidate);