diff options
| author | bors <bors@rust-lang.org> | 2025-05-17 16:28:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-05-17 16:28:16 +0000 |
| commit | bf5a38d118a46fb5fdff90e3dc3cbb58fe618c46 (patch) | |
| tree | 56a95707530044382d6802e830aad804ca1e16ee /compiler/rustc_hir_analysis/src/check/check.rs | |
| parent | 2c12b4a690c8201a3c79f404eec38614684c412c (diff) | |
| parent | 339a46cb727842127eab6212ab13fbb620785312 (diff) | |
| download | rust-bf5a38d118a46fb5fdff90e3dc3cbb58fe618c46.tar.gz rust-bf5a38d118a46fb5fdff90e3dc3cbb58fe618c46.zip | |
Auto merge of #141133 - matthiaskrgr:rollup-u8ndxyz, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #135808 (Implement Display for ``rustc_target::callconv::Conv``) - #137432 (Add as_ascii_unchecked() methods to char, u8, and str) - #139103 (deduplicate abort implementations) - #140917 (checktools.sh: fix bashism) - #141035 (turn lld warning on old gccs into info log) - #141118 (Enable rust-analyzer to go from query definition to the corresponding provider field) - #141121 (Only select true errors in `impossible_predicates`) - #141125 (check coroutines with `TypingMode::Borrowck` to avoid cyclic reasoning) - #141131 (Make some `match`es slightly more ergonomic in `librustdoc`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_hir_analysis/src/check/check.rs')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/check.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index f92b2aea160..da94331aa26 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1754,17 +1754,19 @@ pub(super) fn check_coroutine_obligations( debug!(?typeck_results.coroutine_stalled_predicates); let mode = if tcx.next_trait_solver_globally() { - TypingMode::post_borrowck_analysis(tcx, def_id) + // This query is conceptually between HIR typeck and + // MIR borrowck. We use the opaque types defined by HIR + // and ignore region constraints. + TypingMode::borrowck(tcx, def_id) } else { TypingMode::analysis_in_body(tcx, def_id) }; - let infcx = tcx - .infer_ctxt() - // typeck writeback gives us predicates with their regions erased. - // As borrowck already has checked lifetimes, we do not need to do it again. - .ignoring_regions() - .build(mode); + // Typeck writeback gives us predicates with their regions erased. + // We only need to check the goals while ignoring lifetimes to give good + // error message and to avoid breaking the assumption of `mir_borrowck` + // that all obligations already hold modulo regions. + let infcx = tcx.infer_ctxt().ignoring_regions().build(mode); let ocx = ObligationCtxt::new_with_diagnostics(&infcx); for (predicate, cause) in &typeck_results.coroutine_stalled_predicates { @@ -1785,6 +1787,10 @@ pub(super) fn check_coroutine_obligations( let key = infcx.resolve_vars_if_possible(key); sanity_check_found_hidden_type(tcx, key, hidden_type)?; } + } else { + // We're not checking region constraints here, so we can simply drop the + // added opaque type uses in `TypingMode::Borrowck`. + let _ = infcx.take_opaque_types(); } Ok(()) |
