1
Fork 0

Auto merge of #109753 - compiler-errors:replenish-region-constraints, r=aliemjay

Clone region var origins instead of taking them in borrowck

Fixes an issue with the new solver where reporting a borrow-checker error ICEs because it calls `InferCtxt::evaluate_obligation`.

This also removes a handful of unnecessary `tcx.infer_ctxt().build()` calls that are only there to mitigate this same exact issue, but with the old solver.

Fixes compiler-errors/next-solver-hir-issues#12.

----

This implements `@aliemjay's` solution where we just don't *take* the region constraints, but clone them. This potentially makes it easier to write a bug about taking region constraints twice or never at all, but again, not many folks are touching this code.
This commit is contained in:
bors 2023-04-22 15:15:51 +00:00
commit 4396ceca05
6 changed files with 43 additions and 33 deletions

View file

@ -1228,11 +1228,11 @@ impl<'tcx> InferCtxt<'tcx> {
/// hence that `resolve_regions_and_report_errors` can never be
/// called. This is used only during NLL processing to "hand off" ownership
/// of the set of region variables into the NLL region context.
pub fn take_region_var_origins(&self) -> VarInfos {
pub fn get_region_var_origins(&self) -> VarInfos {
let mut inner = self.inner.borrow_mut();
let (var_infos, data) = inner
.region_constraint_storage
.take()
.clone()
.expect("regions already resolved")
.with_log(&mut inner.undo_log)
.into_infos_and_data();