Skip to content

ICE: cannot relate bound region #109361

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

Closed
Daniel-Anker-Hermansen opened this issue Mar 19, 2023 · 8 comments
Closed

ICE: cannot relate bound region #109361

Daniel-Anker-Hermansen opened this issue Mar 19, 2023 · 8 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Daniel-Anker-Hermansen
Copy link

Code

fn main() {
    foo(bar);
}

fn bar(r: [&usize]) { }

fn foo(f: impl Fn(&[&usize])) { }

Meta

rustc --version --verbose:

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-unknown-linux-gnu
release: 1.68.0
LLVM version: 15.0.6

Error output

error: internal compiler error: compiler/rustc_infer/src/infer/region_constraints/mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ intenal_panic[553d]::bar::'_), '_) }) <= ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed(DefId(0:9 ~ intenal_panic[553d]::foo::'_#1), '_) })
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/compiler/rustc_errors/src/lib.rs:987:33
stack backtrace:
   0:     0x7f274b29659a - std::backtrace_rs::backtrace::libunwind::trace::h595f06c70adcc478
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f274b29659a - std::backtrace_rs::backtrace::trace_unsynchronized::h177a0149c76cdde9
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f274b29659a - std::sys_common::backtrace::_print_fmt::hc0701fd2c3530c58
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f274b29659a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4cd115d8750fd6c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f274b2f839e - core::fmt::write::h93e2f5923c7eca08
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/fmt/mod.rs:1213:17
   5:     0x7f274b286be5 - std::io::Write::write_fmt::h8162dbb45f0b9e62
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/io/mod.rs:1682:15
   6:     0x7f274b296365 - std::sys_common::backtrace::_print::h1835ef8a8f9066da
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f274b296365 - std::sys_common::backtrace::print::hcb5e6388b9235f41
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f274b29912f - std::panicking::default_hook::{{closure}}::h9c084969ccf9a722
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:267:22
   9:     0x7f274b298e6b - std::panicking::default_hook::h68fa2ba3c3c6c12f
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:286:9
  10:     0x7f274e5e56e4 - <rustc_driver[f4ad927b3c57833d]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[d16e85342ea223d9]::ops::function::FnOnce<(&core[d16e85342ea223d9]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f274b29996a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4e6ced11e07d8b24
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/alloc/src/boxed.rs:2002:9
  12:     0x7f274b29996a - std::panicking::rust_panic_with_hook::h8d5c434518ef298c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:692:13
  13:     0x7f274e8a1501 - std[3da461b304582a2c]::panicking::begin_panic::<rustc_errors[41d09747e2f98dea]::ExplicitBug>::{closure#0}
  14:     0x7f274e899e56 - std[3da461b304582a2c]::sys_common::backtrace::__rust_end_short_backtrace::<std[3da461b304582a2c]::panicking::begin_panic<rustc_errors[41d09747e2f98dea]::ExplicitBug>::{closure#0}, !>
  15:     0x7f274e929df6 - std[3da461b304582a2c]::panicking::begin_panic::<rustc_errors[41d09747e2f98dea]::ExplicitBug>
  16:     0x7f274e929de6 - std[3da461b304582a2c]::panic::panic_any::<rustc_errors[41d09747e2f98dea]::ExplicitBug>
  17:     0x7f274e928b92 - <rustc_errors[41d09747e2f98dea]::HandlerInner>::span_bug::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span, &alloc[5b05b59796bdfb5c]::string::String>
  18:     0x7f274e928a37 - <rustc_errors[41d09747e2f98dea]::Handler>::span_bug::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span, &alloc[5b05b59796bdfb5c]::string::String>
  19:     0x7f274e8ddf9b - rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>::{closure#0}
  20:     0x7f274e8ddfea - rustc_middle[eb7209f5870e9fb7]::ty::context::tls::with_opt::<rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f274e8dd0aa - rustc_middle[eb7209f5870e9fb7]::ty::context::tls::with_context_opt::<rustc_middle[eb7209f5870e9fb7]::ty::context::tls::with_opt<rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f274e8dcfd6 - rustc_middle[eb7209f5870e9fb7]::util::bug::opt_span_bug_fmt::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>
  23:     0x7f274e8dcf94 - rustc_middle[eb7209f5870e9fb7]::util::bug::span_bug_fmt::<rustc_span[4bb3e3ecb57f95d5]::span_encoding::Span>
  24:     0x7f274c573fa4 - <rustc_middle[eb7209f5870e9fb7]::ty::sty::Region as rustc_middle[eb7209f5870e9fb7]::ty::relate::Relate>::relate::<rustc_infer[41785f830319e09c]::infer::equate::Equate>
  25:     0x7f274c56e926 - rustc_middle[eb7209f5870e9fb7]::ty::relate::super_relate_tys::<rustc_infer[41785f830319e09c]::infer::equate::Equate>
  26:     0x7f274c56c25e - <rustc_infer[41785f830319e09c]::infer::equate::Equate as rustc_middle[eb7209f5870e9fb7]::ty::relate::TypeRelation>::tys
  27:     0x7f274c56f1ec - rustc_middle[eb7209f5870e9fb7]::ty::relate::super_relate_tys::<rustc_infer[41785f830319e09c]::infer::equate::Equate>
  28:     0x7f274c56c25e - <rustc_infer[41785f830319e09c]::infer::equate::Equate as rustc_middle[eb7209f5870e9fb7]::ty::relate::TypeRelation>::tys
  29:     0x7f274cea5d23 - <rustc_infer[41785f830319e09c]::infer::InferCtxt>::commit_if_ok::<rustc_infer[41785f830319e09c]::infer::InferOk<()>, rustc_middle[eb7209f5870e9fb7]::ty::error::TypeError, <rustc_infer[41785f830319e09c]::infer::at::Trace>::eq<rustc_middle[eb7209f5870e9fb7]::ty::Ty>::{closure#0}>
  30:     0x7f274cea5c16 - <rustc_infer[41785f830319e09c]::infer::at::At>::eq::<rustc_middle[eb7209f5870e9fb7]::ty::Ty>
  31:     0x7f274f1c3bfe - <rustc_infer[41785f830319e09c]::infer::InferCtxt>::can_eq::<rustc_middle[eb7209f5870e9fb7]::ty::Ty>
  32:     0x7f274f1a6b42 - rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::suggestions::hint_missing_borrow
  33:     0x7f274f249fe4 - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::suggestions::TypeErrCtxtExt>::report_closure_arg_mismatch
  34:     0x7f274f259e38 - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  35:     0x7f274f263817 - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  36:     0x7f274f256e7f - <rustc_infer[41785f830319e09c]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[94d7ef6b5a6b8462]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  37:     0x7f274c7ebd65 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_argument_types
  38:     0x7f274d8f30ce - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_call
  39:     0x7f274c7710c2 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  40:     0x7f274c7a6e73 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_block_with_expected
  41:     0x7f274c77154c - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42:     0x7f274c70c071 - <rustc_hir_typeck[7533f7cabd9af3c4]::fn_ctxt::FnCtxt>::check_return_expr
  43:     0x7f274c702fa2 - rustc_hir_typeck[7533f7cabd9af3c4]::check::check_fn
  44:     0x7f274c6eb85e - rustc_hir_typeck[7533f7cabd9af3c4]::typeck
  45:     0x7f274c659bf7 - <rustc_query_system[e5b40bf290de15d8]::dep_graph::graph::DepGraph<rustc_middle[eb7209f5870e9fb7]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[eb7209f5870e9fb7]::ty::context::TyCtxt, rustc_span[4bb3e3ecb57f95d5]::def_id::LocalDefId, &rustc_middle[eb7209f5870e9fb7]::ty::typeck_results::TypeckResults>
  46:     0x7f274c65174b - rustc_query_system[e5b40bf290de15d8]::query::plumbing::try_execute_query::<rustc_query_impl[3a6baddf07124ab7]::queries::typeck, rustc_query_impl[3a6baddf07124ab7]::plumbing::QueryCtxt>
  47:     0x7f274dd38aad - rustc_data_structures[f387d52c0b9780fc]::sync::par_for_each_in::<&[rustc_span[4bb3e3ecb57f95d5]::def_id::LocalDefId], <rustc_middle[eb7209f5870e9fb7]::hir::map::Map>::par_body_owners<rustc_hir_typeck[7533f7cabd9af3c4]::typeck_item_bodies::{closure#0}>::{closure#0}>
  48:     0x7f274dd38853 - rustc_hir_typeck[7533f7cabd9af3c4]::typeck_item_bodies
  49:     0x7f274dd4fa07 - <rustc_query_system[e5b40bf290de15d8]::dep_graph::graph::DepGraph<rustc_middle[eb7209f5870e9fb7]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[eb7209f5870e9fb7]::ty::context::TyCtxt, (), ()>
  50:     0x7f274db628e6 - rustc_query_system[e5b40bf290de15d8]::query::plumbing::try_execute_query::<rustc_query_impl[3a6baddf07124ab7]::queries::typeck_item_bodies, rustc_query_impl[3a6baddf07124ab7]::plumbing::QueryCtxt>
  51:     0x7f274df9eefb - <rustc_query_impl[3a6baddf07124ab7]::Queries as rustc_middle[eb7209f5870e9fb7]::ty::query::QueryEngine>::typeck_item_bodies
  52:     0x7f274ca90892 - <rustc_session[b580c712976fc965]::session::Session>::time::<(), rustc_hir_analysis[9174c993ab369dfd]::check_crate::{closure#7}>
  53:     0x7f274ca8fd12 - rustc_hir_analysis[9174c993ab369dfd]::check_crate
  54:     0x7f274ca8f96b - rustc_interface[3781616314f5d936]::passes::analysis
  55:     0x7f274dd07b16 - <rustc_query_system[e5b40bf290de15d8]::dep_graph::graph::DepGraph<rustc_middle[eb7209f5870e9fb7]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[eb7209f5870e9fb7]::ty::context::TyCtxt, (), core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  56:     0x7f274dd06cd1 - rustc_query_system[e5b40bf290de15d8]::query::plumbing::try_execute_query::<rustc_query_impl[3a6baddf07124ab7]::queries::analysis, rustc_query_impl[3a6baddf07124ab7]::plumbing::QueryCtxt>
  57:     0x7f274df9b7aa - <rustc_query_impl[3a6baddf07124ab7]::Queries as rustc_middle[eb7209f5870e9fb7]::ty::query::QueryEngine>::analysis
  58:     0x7f274d7c5850 - <rustc_interface[3781616314f5d936]::passes::QueryContext>::enter::<rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  59:     0x7f274d7c32c4 - rustc_span[4bb3e3ecb57f95d5]::with_source_map::<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  60:     0x7f274d7bbce4 - <scoped_tls[1a6b834cb64348ef]::ScopedKey<rustc_span[4bb3e3ecb57f95d5]::SessionGlobals>>::set::<rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  61:     0x7f274d7bb3e2 - std[3da461b304582a2c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3781616314f5d936]::util::run_in_thread_pool_with_globals<rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>
  62:     0x7f274d7bb18a - <<std[3da461b304582a2c]::thread::Builder>::spawn_unchecked_<rustc_interface[3781616314f5d936]::util::run_in_thread_pool_with_globals<rustc_interface[3781616314f5d936]::interface::run_compiler<core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>, rustc_driver[f4ad927b3c57833d]::run_compiler::{closure#1}>::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d16e85342ea223d9]::result::Result<(), rustc_errors[41d09747e2f98dea]::ErrorGuaranteed>>::{closure#1} as core[d16e85342ea223d9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  63:     0x7f274b2a3823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1c0f3664d7ced314
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/alloc/src/boxed.rs:1988:9
  64:     0x7f274b2a3823 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h67647c21c6c4968a
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/alloc/src/boxed.rs:1988:9
  65:     0x7f274b2a3823 - std::sys::unix::thread::Thread::new::thread_start::h355d348ba593a22c
                               at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/sys/unix/thread.rs:108:17
  66:     0x7f274afdab43 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  67:     0x7f274b06ca00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  68:                0x0 - <unknown>

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.68.0 (2c8cc3432 2023-03-06) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

@Daniel-Anker-Hermansen Daniel-Anker-Hermansen added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 19, 2023
@langston-barrett
Copy link
Contributor

I can reproduce this on 1.68 but not on nightly.

rustc 1.70.0-nightly (13afbdaa0 2023-03-17)
binary: rustc
commit-hash: 13afbdaa0655dda23d7129e59ac48f1ec88b2084
commit-date: 2023-03-17
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

@jyn514 jyn514 changed the title thread 'rustc' panicked at 'Box<dyn Any>', /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/compiler/rustc_errors/src/lib.rs:987:33 ICE: cannot relate bound region Mar 21, 2023
@jyn514 jyn514 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 21, 2023
@jyn514
Copy link
Member

jyn514 commented Mar 21, 2023

Might be a duplicate of #109420.

@aliemjay
Copy link
Member

The ICE was introduced in #106891 (1.68-stable) and fixed by #107306 (1.69-beta).

This is strictly an error to ICE regression that seems to have a significant impact given the amount of issues reported so far.

@rustbot label regression-from-stable-to-stable

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 21, 2023
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@bugadani
Copy link
Contributor

@jyn514 the linked PR that is supposed to fix this issue has a test and the example code in this issue no longer ICEs. Do you still think E-needs-test is relevant? I can add the test case, but it feels a bit redundant now.

@jyn514
Copy link
Member

jyn514 commented Mar 26, 2023

@bugadani I think we should either stable-nominate the fix PR or close the issue.

@JohnTitor
Copy link
Member

Triage: dropping E-needs-test as it seems that #107306 has a regression test.

@Noratrieb
Copy link
Member

It's now fixed on 1.69.0, no need to keep it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants