Skip to content

ICE: rustc panicked at compiler/rustc_type_ir/src/ty_kind.rs:288:18 with explicit tail call through function pointer #144795

@narpfel

Description

@narpfel

Code

#![feature(explicit_tail_calls)]
#![expect(incomplete_features)]

struct CompiledBytecodes<'a>(&'a [fn(CompiledBytecodes) -> Option<()>]);

fn run_next(compiled_program: CompiledBytecodes) -> Option<()> {
    let next = compiled_program.0.get(0).unwrap();
    become next(compiled_program)
}

(playground link)

Note that replacing .get(0).unwrap() with [0] does not ICE:

#![feature(explicit_tail_calls)]
#![expect(incomplete_features)]

struct CompiledBytecodes<'a>(&'a [fn(CompiledBytecodes) -> Option<()>]);

fn run_next(compiled_program: CompiledBytecodes) -> Option<()> {
    let next = compiled_program.0[0];
    become next(compiled_program)
}

(playground link)

Meta

rustc --version --verbose:

rustc 1.90.0-nightly (adcb3d3b4 2025-07-31)
binary: rustc
commit-hash: adcb3d3b4cd3b7c4cde642f3ed537037f293738e
commit-date: 2025-07-31
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

Error output

<no error>
Backtrace

thread 'rustc' panicked at /rustc-dev/adcb3d3b4cd3b7c4cde642f3ed537037f293738e/compiler/rustc_type_ir/src/ty_kind.rs:288:18:
Ty::fn_sig() called on non-fn type: &'{erased} Binder { value: fn(CompiledBytecodes<'^0.Named(DefId(0:8 ~ playground[57e8]::CompiledBytecodes::'_))>) -> std::option::Option<()>, bound_vars: [Region(BrNamed(DefId(0:8 ~ playground[57e8]::CompiledBytecodes::'_)))] }
stack backtrace:
   0:     0x72bb0adeb653 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he1a7167e1873f128
   1:     0x72bb0b602cf7 - core::fmt::write::hdd082200b2e7e952
   2:     0x72bb0ade1123 - std::io::Write::write_fmt::h0f6e18c78f7bdcae
   3:     0x72bb0adeb4b2 - std::sys::backtrace::BacktraceLock::print::hf819d59eb55a3dcc
   4:     0x72bb0adeef57 - std::panicking::default_hook::{{closure}}::h6076875181d8df4a
   5:     0x72bb0adeeabb - std::panicking::default_hook::hc6d726a7d35b23e7
   6:     0x72bb09e57c83 - std[66aaf2c6a377548e]::panicking::update_hook::<alloc[8819ca7851639877]::boxed::Box<rustc_driver_impl[87c1aa980d595c19]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x72bb0adef79e - std::panicking::rust_panic_with_hook::h145efd09ed4d81a9
   8:     0x72bb0adef49a - std::panicking::begin_panic_handler::{{closure}}::hb3dfecef718fd960
   9:     0x72bb0adebb19 - std::sys::backtrace::__rust_end_short_backtrace::h02d9504e1f4d9495
  10:     0x72bb0adef17d - __rustc[b7f20edcb6d663c5]::rust_begin_unwind
  11:     0x72bb074cdf60 - core::panicking::panic_fmt::hfd4a9e3c69eafb1e
  12:     0x72bb0b63ea63 - <rustc_middle[ff7c21e26af912db]::ty::Ty>::fn_sig
  13:     0x72bb0c4b962b - <rustc_mir_build[e23cf69365fbdc50]::check_tail_calls::TailCallCkVisitor as rustc_middle[ff7c21e26af912db]::thir::visit::Visitor>::visit_expr
  14:     0x72bb0c4b8063 - <rustc_mir_build[e23cf69365fbdc50]::check_tail_calls::TailCallCkVisitor as rustc_middle[ff7c21e26af912db]::thir::visit::Visitor>::visit_expr
  15:     0x72bb0c4b8063 - <rustc_mir_build[e23cf69365fbdc50]::check_tail_calls::TailCallCkVisitor as rustc_middle[ff7c21e26af912db]::thir::visit::Visitor>::visit_expr
  16:     0x72bb0c4b81a2 - <rustc_mir_build[e23cf69365fbdc50]::check_tail_calls::TailCallCkVisitor as rustc_middle[ff7c21e26af912db]::thir::visit::Visitor>::visit_expr
  17:     0x72bb0c4b8063 - <rustc_mir_build[e23cf69365fbdc50]::check_tail_calls::TailCallCkVisitor as rustc_middle[ff7c21e26af912db]::thir::visit::Visitor>::visit_expr
  18:     0x72bb0c4b7973 - rustc_query_impl[44af78eee4108b92]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[44af78eee4108b92]::query_impl::check_tail_calls::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 1usize]>>
  19:     0x72bb0c4bd89f - rustc_query_system[b56f1763c467f231]::query::plumbing::try_execute_query::<rustc_query_impl[44af78eee4108b92]::DynamicConfig<rustc_data_structures[51eedb2b5c74c391]::vec_cache::VecCache<rustc_span[e37d5da3b4f967fc]::def_id::LocalDefId, rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[b56f1763c467f231]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[44af78eee4108b92]::plumbing::QueryCtxt, false>
  20:     0x72bb0c4bd4d1 - rustc_query_impl[44af78eee4108b92]::query_impl::check_tail_calls::get_query_non_incr::__rust_end_short_backtrace
  21:     0x72bb0bbbaa8b - rustc_mir_build[e23cf69365fbdc50]::builder::build_mir
  22:     0x72bb0b609946 - rustc_mir_transform[cc7afc6d6c57d2de]::mir_built
  23:     0x72bb0b609917 - rustc_query_impl[44af78eee4108b92]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[44af78eee4108b92]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 8usize]>>
  24:     0x72bb0bd886ae - rustc_query_system[b56f1763c467f231]::query::plumbing::try_execute_query::<rustc_query_impl[44af78eee4108b92]::DynamicConfig<rustc_data_structures[51eedb2b5c74c391]::vec_cache::VecCache<rustc_span[e37d5da3b4f967fc]::def_id::LocalDefId, rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[b56f1763c467f231]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[44af78eee4108b92]::plumbing::QueryCtxt, false>
  25:     0x72bb0bd88109 - rustc_query_impl[44af78eee4108b92]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  26:     0x72bb0bd14a7e - rustc_mir_build[e23cf69365fbdc50]::check_unsafety::check_unsafety
  27:     0x72bb0bd147df - rustc_query_impl[44af78eee4108b92]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[44af78eee4108b92]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 0usize]>>
  28:     0x72bb0bd0d507 - rustc_query_system[b56f1763c467f231]::query::plumbing::try_execute_query::<rustc_query_impl[44af78eee4108b92]::DynamicConfig<rustc_data_structures[51eedb2b5c74c391]::vec_cache::VecCache<rustc_span[e37d5da3b4f967fc]::def_id::LocalDefId, rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[b56f1763c467f231]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[44af78eee4108b92]::plumbing::QueryCtxt, false>
  29:     0x72bb0bd0d1fd - rustc_query_impl[44af78eee4108b92]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  30:     0x72bb0bd87241 - <rustc_middle[ff7c21e26af912db]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[77dcf312b63517cd]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  31:     0x72bb0bd84e15 - rustc_interface[77dcf312b63517cd]::passes::analysis
  32:     0x72bb0bd84387 - rustc_query_impl[44af78eee4108b92]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[44af78eee4108b92]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 0usize]>>
  33:     0x72bb0c6bccbc - rustc_query_system[b56f1763c467f231]::query::plumbing::try_execute_query::<rustc_query_impl[44af78eee4108b92]::DynamicConfig<rustc_query_system[b56f1763c467f231]::query::caches::SingleCache<rustc_middle[ff7c21e26af912db]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[44af78eee4108b92]::plumbing::QueryCtxt, false>
  34:     0x72bb0c6bc884 - rustc_query_impl[44af78eee4108b92]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x72bb0c69fc8b - rustc_interface[77dcf312b63517cd]::passes::create_and_enter_global_ctxt::<core[3cf706f36e30eb55]::option::Option<rustc_interface[77dcf312b63517cd]::queries::Linker>, rustc_driver_impl[87c1aa980d595c19]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  36:     0x72bb0c8eb871 - rustc_interface[77dcf312b63517cd]::interface::run_compiler::<(), rustc_driver_impl[87c1aa980d595c19]::run_compiler::{closure#0}>::{closure#1}
  37:     0x72bb0c7ad1c1 - std[66aaf2c6a377548e]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[77dcf312b63517cd]::util::run_in_thread_with_globals<rustc_interface[77dcf312b63517cd]::util::run_in_thread_pool_with_globals<rustc_interface[77dcf312b63517cd]::interface::run_compiler<(), rustc_driver_impl[87c1aa980d595c19]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x72bb0c7acea2 - <<std[66aaf2c6a377548e]::thread::Builder>::spawn_unchecked_<rustc_interface[77dcf312b63517cd]::util::run_in_thread_with_globals<rustc_interface[77dcf312b63517cd]::util::run_in_thread_pool_with_globals<rustc_interface[77dcf312b63517cd]::interface::run_compiler<(), rustc_driver_impl[87c1aa980d595c19]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3cf706f36e30eb55]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x72bb0c7b2fc5 - std::sys::pal::unix::thread::Thread::new::thread_start::hd67f5fb492cecf93
  40:     0x72bb0608aaa4 - <unknown>
  41:     0x72bb06117a34 - clone
  42:                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 make sure that you have updated to the latest nightly

note: please attach the file at `/playground/rustc-ice-2025-08-01T19_56_53-26.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 [check_tail_calls] tail-call-checking `run_next`
#1 [mir_built] building MIR for `run_next`
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: could not compile `playground` (lib)

@rustbot label +F-explicit_tail_calls +requires-incomplete-features

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-explicit_tail_calls`#![feature(explicit_tail_calls)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions