Skip to content

thread 'rustc' panicked at 'region constraints already solved' #87709

Closed
@stinodego

Description

@stinodego

Code

Haven't minimized the code yet, but the exact code is up here:
https://github.com/stinodego/gap_solver/tree/360697df92b09e804ce7d0b0f28346a3d13708ee

It's a kind of search algorithm. I think the problematic code is the expand_node function in src/solver.rs. Will report back if I figure out anything more.

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (4e282795d 2021-07-31)
binary: rustc
commit-hash: 4e282795d7d1d28a4c6c1c6521045ae2b59f3519
commit-date: 2021-07-31
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Error output

>>> cargo build
   Compiling gap_solver v0.1.0 (/home/stijn/code/rust/gap_solver)
thread 'rustc' panicked at 'region constraints already solved', compiler/rustc_infer/src/infer/mod.rs:268:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-nightly (4e282795d 2021-07-31) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_borrowck] borrow-checking `solver::expand_node`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `gap_solver`
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/4e282795d7d1d28a4c6c1c6521045ae2b59f3519/library/std/src/panicking.rs:516:5
   1: core::panicking::panic_fmt
             at /rustc/4e282795d7d1d28a4c6c1c6521045ae2b59f3519/library/core/src/panicking.rs:93:14
   2: core::option::expect_failed
             at /rustc/4e282795d7d1d28a4c6c1c6521045ae2b59f3519/library/core/src/option.rs:1578:5
   3: <rustc_infer::infer::canonical::canonicalizer::Canonicalizer as rustc_middle::ty::fold::TypeFolder>::fold_region
   4: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
   5: rustc_middle::ty::fold::TypeFoldable::fold_with
   6: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
   7: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
   8: rustc_middle::ty::fold::TypeFoldable::fold_with
   9: rustc_middle::ty::fold::TypeFoldable::fold_with
  10: rustc_infer::infer::canonical::canonicalizer::Canonicalizer::canonicalize
  11: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  12: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  13: rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions
  14: rustc_mir::borrow_check::diagnostics::move_errors::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::report_move_errors
  15: rustc_mir::borrow_check::do_mir_borrowck
  16: rustc_infer::infer::InferCtxtBuilder::enter
  17: rustc_mir::borrow_check::mir_borrowck
  18: core::ops::function::FnOnce::call_once
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  20: rustc_data_structures::stack::ensure_sufficient_stack
  21: rustc_query_system::query::plumbing::force_query_with_job
  22: rustc_query_system::query::plumbing::get_query_impl
  23: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  24: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  25: rustc_interface::passes::analysis
  26: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::force_query_with_job
  31: rustc_query_system::query::plumbing::get_query_impl
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  33: rustc_interface::passes::QueryContext::enter
  34: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  35: rustc_span::with_source_map
  36: rustc_interface::interface::create_compiler_and_run
  37: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Additional info

I just switched to the stable toolchain, and the compilar gave me two errors:

error[E0507]: cannot move out of `config.agents` which is behind a shared reference
  --> src/solver.rs:48:18
   |
48 |     for agent in config.agents {
   |                  ^^^^^^^^^^^^^ move occurs because `config.agents` has type `BTreeSet<&str>`, which does not implement the `Copy` trait

error[E0596]: cannot borrow `next` as mutable, as it is not declared as mutable
  --> src/solver.rs:72:13
   |
71 |             let next = assignment.clone();
   |                 ---- help: consider changing this to be mutable: `mut next`
72 |             next.assign(agent, t);
   |             ^^^^ cannot borrow as mutable

error: aborting due to 2 previous errors

Apparently these were not caught by the nightly compiler.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions