Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation probe in new solver causes ICE in late borrowck #12

Closed
compiler-errors opened this issue Mar 29, 2023 · 0 comments · Fixed by rust-lang/rust#109753
Closed
Labels
has-fix A fix is up

Comments

@compiler-errors
Copy link
Owner

compiler-errors commented Mar 29, 2023

use std::collections::HashMap;

fn foo() -> &'static HashMap<i32, i32>
{
    &HashMap::new()
}

fn main() {}

Causes:

thread 'rustc' panicked at 'region constraints already solved', compiler/rustc_infer/src/infer/mod.rs:230:14

Since an evaluate_obligation call in the new solver doesn't actually call out to a query, so if we've already taken region constraints, a InferCtxt::probe call will ICE.

@compiler-errors compiler-errors added the needs-cleaner-fix A medium-sized fixed needs to be put up and applied label Mar 29, 2023
@compiler-errors compiler-errors added has-fix A fix is up and removed needs-cleaner-fix A medium-sized fixed needs to be put up and applied labels Mar 30, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 22, 2023
…straints, 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.
RalfJung pushed a commit to RalfJung/miri that referenced this issue Apr 24, 2023
… 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.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 20, 2024
… 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.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-fix A fix is up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant