Skip to content

Commit 5862717

Browse files
Don't erase opaques from typing env for pseudo-canonicalization
1 parent f5cfc52 commit 5862717

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_data_structures::undo_log::{Rollback, UndoLogs};
2020
use rustc_data_structures::unify as ut;
2121
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
2222
use rustc_hir as hir;
23+
use rustc_hir::def::DefKind;
2324
use rustc_hir::def_id::{DefId, LocalDefId};
2425
use rustc_macros::extension;
2526
pub use rustc_macros::{TypeFoldable, TypeVisitable};
@@ -1249,8 +1250,16 @@ impl<'tcx> InferCtxt<'tcx> {
12491250
// to handle them without proper canonicalization. This means we may cause cycle
12501251
// errors and fail to reveal opaques while inside of bodies. We should rename this
12511252
// function and require explicit comments on all use-sites in the future.
1252-
ty::TypingMode::Analysis { defining_opaque_types_and_generators: _ }
1253-
| ty::TypingMode::Borrowck { defining_opaque_types: _ } => {
1253+
ty::TypingMode::Analysis { defining_opaque_types_and_generators } => {
1254+
TypingMode::Analysis {
1255+
defining_opaque_types_and_generators: self.tcx.mk_local_def_ids_from_iter(
1256+
defining_opaque_types_and_generators.iter().filter(|def_id| {
1257+
!matches!(self.tcx.def_kind(*def_id), DefKind::OpaqueTy)
1258+
}),
1259+
),
1260+
}
1261+
}
1262+
ty::TypingMode::Borrowck { defining_opaque_types: _ } => {
12541263
TypingMode::non_body_analysis()
12551264
}
12561265
mode @ (ty::TypingMode::Coherence

compiler/rustc_trait_selection/src/solve/fulfill.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for StalledOnCoroutines<'tcx> {
343343
&& def_id.as_local().is_some_and(|def_id| self.stalled_coroutines.contains(&def_id))
344344
{
345345
return ControlFlow::Break(());
346+
} else if ty.has_coroutines() {
347+
ty.super_visit_with(self)
348+
} else {
349+
ControlFlow::Continue(())
346350
}
347-
348-
ty.super_visit_with(self)
349351
}
350352
}
351353

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,8 +1508,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15081508
defining_opaque_types_and_generators: defining_opaque_types,
15091509
}
15101510
| TypingMode::Borrowck { defining_opaque_types } => {
1511-
defining_opaque_types.is_empty()
1512-
|| (!pred.has_opaque_types() && !pred.has_coroutines())
1511+
defining_opaque_types.is_empty() || !pred.has_opaque_types()
15131512
}
15141513
// The hidden types of `defined_opaque_types` is not local to the current
15151514
// inference context, so we can freely move this to the global cache.

0 commit comments

Comments
 (0)