Open
Description
Code
struct Container<T> {
data: T,
}
fn ice(callback: Box<dyn Fn(Container<&u8>)>) {
let fails: Box<dyn Fn(&Container<&u8>)> = callback;
}
Notes:
- The reference mismatch in function callback arguments is required to repro (
&Container<...>
vsContainer<....>
) - The
Container
needs to take a generic argument to repro, and the argument value needs to be a reference. UsingContainer<u8>
orContainer<Vec<u8>>
does not repro. - Swapping the types of
fails
andcallback
not repro. - Also repros when replacing
Container
with real containers likeVec
orVecDeque
Meta
rustc --version --verbose
:
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
Confirmed bug reproduces on nightly. Traces are from stable.
rustc +nightly --version --verbose
rustc 1.88.0-nightly (e9f8103f9 2025-05-07)
binary: rustc
commit-hash: e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d
commit-date: 2025-05-07
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.4
Error output
thread 'rustc' panicked at /rust/deps/ena-0.14.3/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 1 but the index is 1
Backtrace
Without RUST_BACKTRACE=1
Including since there's a stacktrace here that doesn't appear otherwise
Compiling ice v0.1.0 (/home/user/projects/rust-ice/ice)
thread 'rustc' panicked at /rust/deps/ena-0.14.3/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
0: 0x7f7471bd6e40 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6d42cc84fc840290
1: 0x7f747242867c - core::fmt::write::h5af61a909e3ec64d
2: 0x7f747372ca51 - std::io::Write::write_fmt::h5a7b54aa6e4a315d
3: 0x7f7471bd6ca2 - std::sys::backtrace::BacktraceLock::print::h555579e7396c26ac
4: 0x7f7471bd9122 - std::panicking::default_hook::{{closure}}::h9128866118196224
5: 0x7f7471bd8faa - std::panicking::default_hook::h52e9e7314e0255f6
6: 0x7f7470d33449 - std[d9e466a2d75004a2]::panicking::update_hook::<alloc[54bfe2542ace865d]::boxed::Box<rustc_driver_impl[680c351c5444d7cd]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f7471bd9ca3 - std::panicking::rust_panic_with_hook::h541791bcc774ef34
8: 0x7f7471bd999a - std::panicking::begin_panic_handler::{{closure}}::h6479a2f0137c7d19
9: 0x7f7471bd7329 - std::sys::backtrace::__rust_end_short_backtrace::ha04e7c0fc61ded91
10: 0x7f7471bd965d - rust_begin_unwind
11: 0x7f746e83d920 - core::panicking::panic_fmt::h5764ee7030b7a73d
12: 0x7f7470459089 - core::panicking::panic_bounds_check::h0328ca7e7f0749c4
13: 0x7f74738f7ce7 - <ena[1fe2efd429ac361d]::unify::UnificationTable<ena[1fe2efd429ac361d]::unify::backing_vec::InPlace<rustc_infer[86fba76a03fa934a]::infer::unify_key::RegionVidKey, &mut alloc[54bfe2542ace865d]::vec::Vec<ena[1fe2efd429ac361d]::unify::VarValue<rustc_infer[86fba76a03fa934a]::infer::unify_key::RegionVidKey>>, &mut rustc_infer[86fba76a03fa934a]::infer::snapshot::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key.cold
14: 0x7f747258a7d3 - rustc_type_ir[282c50670f22d67a]::relate::structurally_relate_tys::<rustc_middle[a78c8f6c75429410]::ty::context::TyCtxt, rustc_infer[86fba76a03fa934a]::infer::relate::type_relating::TypeRelating>::{closure#0}
15: 0x7f74725857a1 - <rustc_infer[86fba76a03fa934a]::infer::relate::type_relating::TypeRelating as rustc_type_ir[282c50670f22d67a]::relate::TypeRelation<rustc_middle[a78c8f6c75429410]::ty::context::TyCtxt>>::tys
16: 0x7f7472589f17 - rustc_type_ir[282c50670f22d67a]::relate::structurally_relate_tys::<rustc_middle[a78c8f6c75429410]::ty::context::TyCtxt, rustc_infer[86fba76a03fa934a]::infer::relate::type_relating::TypeRelating>::{closure#0}
17: 0x7f74725857a1 - <rustc_infer[86fba76a03fa934a]::infer::relate::type_relating::TypeRelating as rustc_type_ir[282c50670f22d67a]::relate::TypeRelation<rustc_middle[a78c8f6c75429410]::ty::context::TyCtxt>>::tys
18: 0x7f7472583e96 - <rustc_infer[86fba76a03fa934a]::infer::at::At>::eq_trace::<rustc_middle[a78c8f6c75429410]::ty::Ty>
19: 0x7f7470f3386c - <rustc_infer[86fba76a03fa934a]::infer::InferCtxt>::probe::<bool, <rustc_infer[86fba76a03fa934a]::infer::InferCtxt as rustc_trait_selection[2bf3b2046bc969f2]::infer::InferCtxtExt>::can_eq<rustc_middle[a78c8f6c75429410]::ty::Ty>::{closure#0}>
20: 0x7f7471024760 - <rustc_hir_typeck[5fc4f412604a8286]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
21: 0x7f74731213a5 - <rustc_hir_typeck[5fc4f412604a8286]::fn_ctxt::FnCtxt>::check_decl
22: 0x7f747311d73f - <rustc_hir_typeck[5fc4f412604a8286]::fn_ctxt::FnCtxt>::check_expr_block
23: 0x7f747312441e - <rustc_hir_typeck[5fc4f412604a8286]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
24: 0x7f7472811c46 - rustc_hir_typeck[5fc4f412604a8286]::check::check_fn
25: 0x7f747281a281 - rustc_hir_typeck[5fc4f412604a8286]::typeck_with_inspect::{closure#0}
26: 0x7f747281828c - rustc_query_impl[abff21d8349146d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[abff21d8349146d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 8usize]>>
27: 0x7f747280c37e - rustc_query_system[9464b8c501ef87f3]::query::plumbing::try_execute_query::<rustc_query_impl[abff21d8349146d]::DynamicConfig<rustc_data_structures[6e992f72641bf6c6]::vec_cache::VecCache<rustc_span[15ded62729b25549]::def_id::LocalDefId, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[9464b8c501ef87f3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[abff21d8349146d]::plumbing::QueryCtxt, true>
28: 0x7f747289748e - rustc_query_impl[abff21d8349146d]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
29: 0x7f74728086d5 - <rustc_middle[a78c8f6c75429410]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[f9dd0ea7be29e3be]::check_crate::{closure#3}>::{closure#0}
30: 0x7f7472807d45 - rustc_hir_analysis[f9dd0ea7be29e3be]::check_crate
31: 0x7f74728028ab - rustc_interface[84ab11ffe8dacd23]::passes::run_required_analyses
32: 0x7f7472f18f1e - rustc_interface[84ab11ffe8dacd23]::passes::analysis
33: 0x7f7472f18eef - rustc_query_impl[abff21d8349146d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[abff21d8349146d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 0usize]>>
34: 0x7f747344ef93 - rustc_query_system[9464b8c501ef87f3]::query::plumbing::try_execute_query::<rustc_query_impl[abff21d8349146d]::DynamicConfig<rustc_query_system[9464b8c501ef87f3]::query::caches::SingleCache<rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[abff21d8349146d]::plumbing::QueryCtxt, true>
35: 0x7f747344e915 - rustc_query_impl[abff21d8349146d]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
36: 0x7f747339aea9 - rustc_interface[84ab11ffe8dacd23]::passes::create_and_enter_global_ctxt::<core[46aa9df3d3dcdeb1]::option::Option<rustc_interface[84ab11ffe8dacd23]::queries::Linker>, rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
37: 0x7f74733ab726 - rustc_interface[84ab11ffe8dacd23]::interface::run_compiler::<(), rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}>::{closure#1}
38: 0x7f74732e0744 - std[d9e466a2d75004a2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_with_globals<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_pool_with_globals<rustc_interface[84ab11ffe8dacd23]::interface::run_compiler<(), rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
39: 0x7f74732e0419 - <<std[d9e466a2d75004a2]::thread::Builder>::spawn_unchecked_<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_with_globals<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_pool_with_globals<rustc_interface[84ab11ffe8dacd23]::interface::run_compiler<(), rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[46aa9df3d3dcdeb1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
40: 0x7f74732dfbaf - std::sys::pal::unix::thread::Thread::new::thread_start::hcc5ed016d554f327
41: 0x7f746d475aa4 - <unknown>
42: 0x7f746d502c3c - <unknown>
43: 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: rustc 1.86.0 (05f9846f8 2025-03-31) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -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 `ice`
#1 [analysis] running analysis passes on this crate
end of query stack
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: `TypeError` when attempting coercion but no error emitted
--> src/lib.rs:6:47
|
6 | let fails: Box<dyn Fn(&Container<&u8>)> = callback;
| ^^^^^^^^
|
note: delayed at compiler/rustc_hir_typeck/src/demand.rs:273:47 - disabled backtrace
--> src/lib.rs:6:47
|
6 | let fails: Box<dyn Fn(&Container<&u8>)> = callback;
| ^^^^^^^^
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.86.0 (05f9846f8 2025-03-31) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -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:
end of query stack
error: could not compile `ice` (lib)
Caused by:
process didn't exit successfully: `/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name ice --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=cb5a12b6d550384b -C extra-filename=-f11bb989a7d34b0a --out-dir /home/user/projects/rust-ice/ice/target/debug/deps -C incremental=/home/user/projects/rust-ice/ice/target/debug/incremental -L dependency=/home/user/projects/rust-ice/ice/target/debug/deps` (exit status: 101)
With RUST_BACKTRACE=1
Compiling ice v0.1.0 (/home/user/projects/rust-ice/ice)
thread 'rustc' panicked at /rust/deps/ena-0.14.3/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic_bounds_check
3: <ena::unify::UnificationTable<ena::unify::backing_vec::InPlace<rustc_infer::infer::unify_key::RegionVidKey, &mut alloc::vec::Vec<ena::unify::VarValue<rustc_infer::infer::unify_key::RegionVidKey>>, &mut rustc_infer::infer::snapshot::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key.cold
4: rustc_type_ir::relate::structurally_relate_tys::<rustc_middle::ty::context::TyCtxt, rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#0}
5: <rustc_infer::infer::relate::type_relating::TypeRelating as rustc_type_ir::relate::TypeRelation<rustc_middle::ty::context::TyCtxt>>::tys
6: rustc_type_ir::relate::structurally_relate_tys::<rustc_middle::ty::context::TyCtxt, rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#0}
7: <rustc_infer::infer::relate::type_relating::TypeRelating as rustc_type_ir::relate::TypeRelation<rustc_middle::ty::context::TyCtxt>>::tys
8: <rustc_infer::infer::at::At>::eq_trace::<rustc_middle::ty::Ty>
9: <rustc_infer::infer::InferCtxt>::probe::<bool, <rustc_infer::infer::InferCtxt as rustc_trait_selection::infer::InferCtxtExt>::can_eq<rustc_middle::ty::Ty>::{closure#0}>
10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::emit_coerce_suggestions
11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl
12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
14: rustc_hir_typeck::check::check_fn
15: rustc_hir_typeck::typeck_with_inspect::{closure#0}
[... omitted 1 frame ...]
16: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
17: rustc_hir_analysis::check_crate
18: rustc_interface::passes::run_required_analyses
19: rustc_interface::passes::analysis
[... omitted 1 frame ...]
20: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
21: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: rustc 1.86.0 (05f9846f8 2025-03-31) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -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 `ice`
#1 [analysis] running analysis passes on this crate
end of query stack
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: `TypeError` when attempting coercion but no error emitted
--> src/lib.rs:6:47
|
6 | let fails: Box<dyn Fn(&Container<&u8>)> = callback;
| ^^^^^^^^
|
note: delayed at compiler/rustc_hir_typeck/src/demand.rs:273:47
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl
5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
7: rustc_hir_typeck::check::check_fn
8: rustc_hir_typeck::typeck_with_inspect::{closure#0}
9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
11: rustc_query_impl::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
12: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#3}>::{closure#0}
13: rustc_hir_analysis::check_crate
14: rustc_interface::passes::run_required_analyses
15: rustc_interface::passes::analysis
16: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
18: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
19: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
21: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
22: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
23: std::sys::pal::unix::thread::Thread::new::thread_start
24: <unknown>
25: <unknown>
--> src/lib.rs:6:47
|
6 | let fails: Box<dyn Fn(&Container<&u8>)> = callback;
| ^^^^^^^^
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.86.0 (05f9846f8 2025-03-31) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib -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:
end of query stack
error: could not compile `ice` (lib)
Caused by:
process didn't exit successfully: `/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name ice --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=cb5a12b6d550384b -C extra-filename=-f11bb989a7d34b0a --out-dir /home/user/projects/rust-ice/ice/target/debug/deps -C incremental=/home/user/projects/rust-ice/ice/target/debug/incremental -L dependency=/home/user/projects/rust-ice/ice/target/debug/deps` (exit status: 101)
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: a bisection has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.This issue may need triage. Remove it if it has been sufficiently triaged.