Clone region var origins instead of taking them in borrowck#109753
Clone region var origins instead of taking them in borrowck#109753bors merged 1 commit intorust-lang:masterfrom
Conversation
|
(rustbot has picked a reviewer for you, use r? to override) |
|
Grr, meant to |
There was a problem hiding this comment.
| // This should only happen on an error path, so delay a bug. | |
| // This should only happen on an error path, so delay a bug. | |
| // | |
| // This is only allowed so one can use the existing inference | |
| // context for diagnostics. |
There was a problem hiding this comment.
I don't think RegionConstraintStorage::default() is a sane value. This resets the region variables counter and thus nullifies the whole point of using the existing InferCtxt.
How about changing InferCtxt::take_region_var_origins to clone region VarInfos instead of removing them? and probably using better name for it.
There was a problem hiding this comment.
Maybe we can keep it named take_ name, but set some flag that the infos have been taken, and delay a bug if we try to take them again or try to borrow them again?
There was a problem hiding this comment.
Mm, I have no strong opinion here, but I don't like delaying a bug in InferCtxt. I prefer the code there to be independent from the compilation session as much as possible.
Changing take_region_var_infos is unfortunate as it would no longer guard against future addition of region constraints, but I think it's the best option here given that it's used only once in borrowck and we don't expect users of InferCtxt to implement their own region resolution.
|
☔ The latest upstream changes (presumably #109849) made this pull request unmergeable. Please resolve the merge conflicts. |
4e1c9b3 to
08101d6
Compare
|
Ok, took the alternative approach. @rustbot ready |
08101d6 to
3d604ea
Compare
There was a problem hiding this comment.
I think it's worth keeping this Option and clearing it in InferCtxt::{resolve_regions,skip_region_resolution} . This way limit this hack to MIR borrowck, rather that lexical region resolver which is more commonly used.
3d604ea to
72ffa11
Compare
InferCtxt::probe is called after resolve_regions|
Ok, changed it back to @bors r=aliemjay |
|
📌 Commit 72ffa1160aab7b92a20260c3bbe651119935952e has been approved by It is now in the queue for this repository. |
|
☔ The latest upstream changes (presumably #110458) made this pull request unmergeable. Please resolve the merge conflicts. |
72ffa11 to
964600b
Compare
|
Rebased @bors r=aliemjay |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (4396cec): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
…r=compiler-errors Fix comment for `get_region_var_origins` rust-lang#109753 changed the logic but not the comment. r? `@compiler-errors`
This was first renamed to `get_region_var_origins` in rust-lang/rust#109753, and then to `get_region_var_infos` in rust-lang/rust@b0fc1d4
This was first renamed to `get_region_var_origins` in rust-lang#109753, and then to `get_region_var_infos` in rust-lang@b0fc1d4
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.