Open
Description
Code
When compiling the following Rust code without enabling the generic_const_exprs feature
flag, it doesn't trigger an ICE :
#![feature(generic_const_exprs)]
fn foo<'a>()
where [(); {let _: &'a ();}]== [(); {let _: &'a ();}]
{
//code
}
The provided Rust code triggers an ICE (Internal Compiler Error) during the type-checking of a generic constant expression. The error message indicates a query stack overflow, which occurs when the compiler's query mechanism encounters a recursion or excessive depth.
Meta
rustc --version --verbose
:
rustc 1.74.0-nightly (ec08a0337 2023-09-04)
binary: rustc
commit-hash: ec08a0337f3556212525dbf1d3b41e19bdf27621
commit-date: 2023-09-04
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0
what's more, The above code also triggers an ICE error on rustc stable 1.72.
Error output
Compiling playground v0.0.1 (/playground)
error: equality constraints are not yet supported in `where` clauses
--> src/lib.rs:3:11
|
3 | where [(); {let _: &'a ();}]== [(); {let _: &'a ();}]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not supported
|
= note: [see issue #20041 <https://github.com/rust-lang/rust/issues/20041>](https://github.com/rust-lang/rust/issues/20041) for more information
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/lib.rs:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: [see issue #76560 <https://github.com/rust-lang/rust/issues/76560>](https://github.com/rust-lang/rust/issues/76560) for more information
= note: `#[warn(incomplete_features)]` on by default
Backtrace
thread 'rustc' panicked at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:480:13:
`WellFormed(&'a ())` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
0: 0x7f493d5cabec - std::backtrace_rs::backtrace::libunwind::trace::hbfb1354a0607bd0b
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f493d5cabec - std::backtrace_rs::backtrace::trace_unsynchronized::h0d86af43cec18792
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f493d5cabec - std::sys_common::backtrace::_print_fmt::h1a9ad677b5782f05
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7f493d5cabec - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6f7239a9a00dd18b
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f493d630dfc - core::fmt::rt::Argument::fmt::had320c4aae37cefe
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/core/src/fmt/rt.rs:138:9
5: 0x7f493d630dfc - core::fmt::write::hcb58283862b95e8f
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/core/src/fmt/mod.rs:1094:21
6: 0x7f493d5bd62e - std::io::Write::write_fmt::h4981a40f92225957
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/io/mod.rs:1714:15
7: 0x7f493d5ca9d4 - std::sys_common::backtrace::_print::h4bd0ac2934ee7fe5
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f493d5ca9d4 - std::sys_common::backtrace::print::h2f959f92d1015729
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f493d5cdaca - std::panicking::panic_hook_with_disk_dump::{{closure}}::hd394741097a335b6
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/panicking.rs:280:22
10: 0x7f493d5cd7c5 - std::panicking::panic_hook_with_disk_dump::he0c37b922f0af64d
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/panicking.rs:314:9
11: 0x7f4940775309 - <rustc_driver_impl[a3bf754034e95f9f]::install_ice_hook::{closure#0} as core[ca4201306d049fa9]::ops::function::FnOnce<(&core[ca4201306d049fa9]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
12: 0x7f493d5ce383 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h716fa69b5a80630f
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/alloc/src/boxed.rs:2021:9
13: 0x7f493d5ce383 - std::panicking::rust_panic_with_hook::hba72365e18906222
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/panicking.rs:757:13
14: 0x7f493d5ce101 - std::panicking::begin_panic_handler::{{closure}}::h787568b8d16a1978
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/panicking.rs:631:13
15: 0x7f493d5cb116 - std::sys_common::backtrace::__rust_end_short_backtrace::h479917b180d73d24
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/sys_common/backtrace.rs:170:18
16: 0x7f493d5cde42 - rust_begin_unwind
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/panicking.rs:619:5
17: 0x7f493d62d1a5 - core::panicking::panic_fmt::h549e4fe39f7e4186
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/core/src/panicking.rs:72:14
18: 0x7f493ea09b84 - <rustc_hir_typeck[381cd940586e0de2]::fn_ctxt::FnCtxt>::register_wf_obligation
19: 0x7f493ea09905 - <rustc_hir_typeck[381cd940586e0de2]::fn_ctxt::FnCtxt>::to_ty
20: 0x7f493e99355d - <rustc_hir_typeck[381cd940586e0de2]::gather_locals::GatherLocalsVisitor as rustc_hir[83ffa566f3d26d1]::intravisit::Visitor>::visit_local
21: 0x7f493e991c9e - <rustc_hir_typeck[381cd940586e0de2]::gather_locals::GatherLocalsVisitor as rustc_hir[83ffa566f3d26d1]::intravisit::Visitor>::visit_expr
22: 0x7f493f8d6f5e - rustc_hir_typeck[381cd940586e0de2]::typeck
23: 0x7f493e8a5ade - rustc_query_impl[771e3cb305a0dac9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[771e3cb305a0dac9]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 8usize]>>
24: 0x7f493e8a5aae - <rustc_query_impl[771e3cb305a0dac9]::query_impl::typeck::dynamic_query::{closure#2} as core[ca4201306d049fa9]::ops::function::FnOnce<(rustc_middle[6c892fc15eeb424e]::ty::context::TyCtxt, rustc_span[3392f19fbbd364f8]::def_id::LocalDefId)>>::call_once
25: 0x7f493e98dd38 - rustc_query_system[6395160b0cddfe06]::query::plumbing::try_execute_query::<rustc_query_impl[771e3cb305a0dac9]::DynamicConfig<rustc_query_system[6395160b0cddfe06]::query::caches::VecCache<rustc_span[3392f19fbbd364f8]::def_id::LocalDefId, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[771e3cb305a0dac9]::plumbing::QueryCtxt, false>
26: 0x7f4940107371 - rustc_query_impl[771e3cb305a0dac9]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
27: 0x7f493f19edaa - rustc_mir_build[5d9174c4e6dc5447]::thir::cx::thir_body
28: 0x7f493e88bc31 - rustc_query_impl[771e3cb305a0dac9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[771e3cb305a0dac9]::query_impl::thir_body::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 16usize]>>
29: 0x7f493ee2eea2 - rustc_query_system[6395160b0cddfe06]::query::plumbing::try_execute_query::<rustc_query_impl[771e3cb305a0dac9]::DynamicConfig<rustc_query_system[6395160b0cddfe06]::query::caches::VecCache<rustc_span[3392f19fbbd364f8]::def_id::LocalDefId, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[771e3cb305a0dac9]::plumbing::QueryCtxt, false>
30: 0x7f49400fcd24 - rustc_query_impl[771e3cb305a0dac9]::query_impl::thir_body::get_query_non_incr::__rust_end_short_backtrace
31: 0x7f493eb6b78f - rustc_query_impl[771e3cb305a0dac9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[771e3cb305a0dac9]::query_impl::thir_abstract_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 16usize]>>
32: 0x7f493eb6b675 - <rustc_query_impl[771e3cb305a0dac9]::query_impl::thir_abstract_const::dynamic_query::{closure#2} as core[ca4201306d049fa9]::ops::function::FnOnce<(rustc_middle[6c892fc15eeb424e]::ty::context::TyCtxt, rustc_span[3392f19fbbd364f8]::def_id::DefId)>>::call_once
33: 0x7f493e8f9095 - rustc_query_system[6395160b0cddfe06]::query::plumbing::try_execute_query::<rustc_query_impl[771e3cb305a0dac9]::DynamicConfig<rustc_query_system[6395160b0cddfe06]::query::caches::DefaultCache<rustc_span[3392f19fbbd364f8]::def_id::DefId, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[771e3cb305a0dac9]::plumbing::QueryCtxt, false>
34: 0x7f49400fd8c5 - rustc_query_impl[771e3cb305a0dac9]::query_impl::thir_abstract_const::get_query_non_incr::__rust_end_short_backtrace
35: 0x7f493e8f820d - rustc_middle[6c892fc15eeb424e]::query::plumbing::query_get_at::<rustc_query_system[6395160b0cddfe06]::query::caches::DefaultCache<rustc_span[3392f19fbbd364f8]::def_id::DefId, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 16usize]>>>
36: 0x7f493e8f4255 - <<rustc_middle[6c892fc15eeb424e]::ty::context::TyCtxt>::expand_abstract_consts::Expander as rustc_type_ir[946165c0ef8d5474]::fold::TypeFolder<rustc_middle[6c892fc15eeb424e]::ty::context::TyCtxt>>::fold_const
37: 0x7f493eae03c7 - rustc_trait_selection[1e6526734a7ec9ab]::traits::const_evaluatable::is_const_evaluatable
38: 0x7f493ea885a8 - <rustc_trait_selection[1e6526734a7ec9ab]::traits::fulfill::FulfillProcessor as rustc_data_structures[5c4fe5736e6441b2]::obligation_forest::ObligationProcessor>::process_obligation
39: 0x7f493ea7e444 - <rustc_data_structures[5c4fe5736e6441b2]::obligation_forest::ObligationForest<rustc_trait_selection[1e6526734a7ec9ab]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[1e6526734a7ec9ab]::traits::fulfill::FulfillProcessor>
40: 0x7f493f08bb45 - <rustc_trait_selection[1e6526734a7ec9ab]::traits::engine::ObligationCtxt>::assumed_wf_types_and_report_errors
41: 0x7f493f0832cd - rustc_hir_analysis[3e296a520ebedb8b]::check::wfcheck::check_item_fn
42: 0x7f493f07c6d1 - rustc_hir_analysis[3e296a520ebedb8b]::check::wfcheck::check_well_formed
43: 0x7f493e8650ac - rustc_query_impl[771e3cb305a0dac9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[771e3cb305a0dac9]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 0usize]>>
44: 0x7f493f0ec49b - rustc_query_system[6395160b0cddfe06]::query::plumbing::try_execute_query::<rustc_query_impl[771e3cb305a0dac9]::DynamicConfig<rustc_query_system[6395160b0cddfe06]::query::caches::VecCache<rustc_hir[83ffa566f3d26d1]::hir_id::OwnerId, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[771e3cb305a0dac9]::plumbing::QueryCtxt, false>
45: 0x7f493f0ec1a4 - rustc_query_impl[771e3cb305a0dac9]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
46: 0x7f493faf5b42 - <rustc_middle[6c892fc15eeb424e]::hir::ModuleItems>::par_items::<rustc_hir_analysis[3e296a520ebedb8b]::check::wfcheck::check_mod_type_wf::{closure#0}>
47: 0x7f493faf575d - rustc_hir_analysis[3e296a520ebedb8b]::check::wfcheck::check_mod_type_wf
48: 0x7f493f457c5c - rustc_query_impl[771e3cb305a0dac9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[771e3cb305a0dac9]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 0usize]>>
49: 0x7f493f457c3e - <rustc_query_impl[771e3cb305a0dac9]::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core[ca4201306d049fa9]::ops::function::FnOnce<(rustc_middle[6c892fc15eeb424e]::ty::context::TyCtxt, rustc_span[3392f19fbbd364f8]::def_id::LocalModDefId)>>::call_once
50: 0x7f493f7adbe8 - rustc_query_system[6395160b0cddfe06]::query::plumbing::try_execute_query::<rustc_query_impl[771e3cb305a0dac9]::DynamicConfig<rustc_query_system[6395160b0cddfe06]::query::caches::DefaultCache<rustc_span[3392f19fbbd364f8]::def_id::LocalModDefId, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[771e3cb305a0dac9]::plumbing::QueryCtxt, false>
51: 0x7f4940106cf4 - rustc_query_impl[771e3cb305a0dac9]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
52: 0x7f493fbef33e - rustc_data_structures[5c4fe5736e6441b2]::sync::par_for_each_in::<&[rustc_hir[83ffa566f3d26d1]::hir_id::OwnerId], <rustc_middle[6c892fc15eeb424e]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[3e296a520ebedb8b]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
53: 0x7f493fbee3ea - rustc_hir_analysis[3e296a520ebedb8b]::check_crate
54: 0x7f493fbe7712 - rustc_interface[8114ca1f21f3221d]::passes::analysis
55: 0x7f493fc068aa - rustc_query_impl[771e3cb305a0dac9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[771e3cb305a0dac9]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 1usize]>>
56: 0x7f493fc06899 - <rustc_query_impl[771e3cb305a0dac9]::query_impl::analysis::dynamic_query::{closure#2} as core[ca4201306d049fa9]::ops::function::FnOnce<(rustc_middle[6c892fc15eeb424e]::ty::context::TyCtxt, ())>>::call_once
57: 0x7f493fec0c74 - rustc_query_system[6395160b0cddfe06]::query::plumbing::try_execute_query::<rustc_query_impl[771e3cb305a0dac9]::DynamicConfig<rustc_query_system[6395160b0cddfe06]::query::caches::SingleCache<rustc_middle[6c892fc15eeb424e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[771e3cb305a0dac9]::plumbing::QueryCtxt, false>
58: 0x7f493fec09e9 - rustc_query_impl[771e3cb305a0dac9]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
59: 0x7f493fdb0323 - <rustc_middle[6c892fc15eeb424e]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[a3bf754034e95f9f]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[ca4201306d049fa9]::result::Result<(), rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>>
60: 0x7f493fcb919c - <rustc_interface[8114ca1f21f3221d]::interface::Compiler>::enter::<rustc_driver_impl[a3bf754034e95f9f]::run_compiler::{closure#1}::{closure#2}, core[ca4201306d049fa9]::result::Result<core[ca4201306d049fa9]::option::Option<rustc_interface[8114ca1f21f3221d]::queries::Linker>, rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>>
61: 0x7f493fcb0038 - std[4630b4a01c2a899b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8114ca1f21f3221d]::util::run_in_thread_with_globals<rustc_interface[8114ca1f21f3221d]::interface::run_compiler<core[ca4201306d049fa9]::result::Result<(), rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>, rustc_driver_impl[a3bf754034e95f9f]::run_compiler::{closure#1}>::{closure#0}, core[ca4201306d049fa9]::result::Result<(), rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ca4201306d049fa9]::result::Result<(), rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>>
62: 0x7f493fcaf7ae - <<std[4630b4a01c2a899b]::thread::Builder>::spawn_unchecked_<rustc_interface[8114ca1f21f3221d]::util::run_in_thread_with_globals<rustc_interface[8114ca1f21f3221d]::interface::run_compiler<core[ca4201306d049fa9]::result::Result<(), rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>, rustc_driver_impl[a3bf754034e95f9f]::run_compiler::{closure#1}>::{closure#0}, core[ca4201306d049fa9]::result::Result<(), rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ca4201306d049fa9]::result::Result<(), rustc_span[3392f19fbbd364f8]::ErrorGuaranteed>>::{closure#1} as core[ca4201306d049fa9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
63: 0x7f493d5d8d35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h183bb945d1c40ecd
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/alloc/src/boxed.rs:2007:9
64: 0x7f493d5d8d35 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h791fe323d569b2e6
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/alloc/src/boxed.rs:2007:9
65: 0x7f493d5d8d35 - std::sys::unix::thread::Thread::new::thread_start::hf784ac242542a57b
at /rustc/ec08a0337f3556212525dbf1d3b41e19bdf27621/library/std/src/sys/unix/thread.rs:108:17
66: 0x7f493d49e609 - start_thread
67: 0x7f493d3c1133 - clone
68: 0x0 - <unknown>
error: 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: please attach the file at `/playground/rustc-ice-2023-09-05T06:55:14.334764402Z-18.txt` to your bug report
note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [typeck] type-checking `foo::{constant#1}`
#1 [thir_body] building THIR for `foo::{constant#1}`
#2 [thir_abstract_const] building an abstract representation for `foo::{constant#1}`
#3 [check_well_formed] checking that `foo` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
warning: `playground` (lib) generated 1 warning
error: could not compile `playground` (lib) due to previous error; 1 warning emitted