Skip to content

[ICE]: attempt to subtract with overflow #158800

Description

@matthiaskrgr

snippet:

impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }

Version information

rustc 1.98.0-nightly (ea088e0a3 2026-07-05)
binary: rustc
commit-hash: ea088e0a3dd50c494b4589c3c121d7469dceec8f
commit-date: 2026-07-05
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

let has_implicit_self = hir_decl.implicit_self().has_implicit_self();
let mut inputs = sig.inputs().iter().skip(if has_implicit_self { 1 } else { 0 });
// FIXME(splat): support the rest of closure splatting, or replace this code with an error
if let Some(mut splatted_arg_index) = sig.splatted() {
let mut inputs_count = sig.inputs().len();
if has_implicit_self {
splatted_arg_index = splatted_arg_index.strict_sub(1);
inputs_count = inputs_count.strict_sub(1);
}
debug!(?splatted_arg_index, ?inputs_count, ?has_implicit_self, ?sig);
sig = sig.set_splatted(Some(splatted_arg_index), inputs_count).unwrap();
}
// Check that the argument is a tuple and is sized

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected one of `->`, `where`, or `{`, found `}`
 --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:62
  |
1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |                                     ---------                ^ expected one of `->`, `where`, or `{`
  |                                     |
  |                                     while parsing this `fn`

error: associated function in `impl` without body
 --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:15
  |
1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: provide a definition for the function: `{ <body> }`

error[E0658]: the `#[splat]` attribute is an experimental feature
 --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:47
  |
1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |                                               ^^^^^^^^
  |
  = note: see issue #153629 <https://github.com/rust-lang/rust/issues/153629> for more information
  = help: add `#![feature(splat)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-05; consider upgrading it if it is out of date
  = note: the `#[splat]` attribute is experimental

error[E0658]: the extern "rust-call" ABI is experimental and subject to change
 --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:22
  |
1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |                      ^^^^^^^^^^^
  |
  = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
  = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-05; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:63
  |
1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |                                                               ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs`

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:6
  |
1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |      ^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
  |
1 | impl dyn FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |      +++
help: you might have intended to implement this trait for a given type
  |
1 | impl FnOnce for /* Type */ { extern "rust-call" fn call_once(#[splat] self) }
  |             ++++++++++++++

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
 --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:6
  |
1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
  |      ^^^^^^ help: use parenthetical notation instead: `FnOnce() -> ()`
  |
  = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
  = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-05; consider upgrading it if it is out of date

error[E0107]: missing generics for trait `FnOnce`
   --> /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:6
    |
  1 | impl FnOnce { extern "rust-call" fn call_once(#[splat] self) }
    |      ^^^^^^ expected 1 generic argument
    |
note: trait defined here, with 1 generic parameter: `Args`
   --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/ops/function.rs:242:17
    |
242 | pub const trait FnOnce<Args: Tuple> {
    |                 ^^^^^^ ----
help: add missing generic argument
    |
  1 | impl FnOnce<Args> { extern "rust-call" fn call_once(#[splat] self) }
    |            ++++++


thread 'rustc' (2171534) panicked at /rustc-dev/ea088e0a3dd50c494b4589c3c121d7469dceec8f/compiler/rustc_hir_analysis/src/check/wfcheck.rs:1723:57:
attempt to subtract with overflow
stack backtrace:
   0:     0x7f20cd4e5ea6 - <<std[1023ab8fe43ea5ab]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[ac254214b649f1de]::fmt::Display>::fmt
   1:     0x7f20cdc0ecc8 - core[ac254214b649f1de]::fmt::write
   2:     0x7f20cd4fb28c - <std[1023ab8fe43ea5ab]::sys::stdio::unix::Stderr as std[1023ab8fe43ea5ab]::io::Write>::write_fmt
   3:     0x7f20cd4ba30a - std[1023ab8fe43ea5ab]::panicking::default_hook::{closure#0}
   4:     0x7f20cd4d85f3 - std[1023ab8fe43ea5ab]::panicking::default_hook
   5:     0x7f20cc4c45b8 - std[1023ab8fe43ea5ab]::panicking::update_hook::<alloc[e3e2338491c50a85]::boxed::Box<rustc_driver_impl[cdfcb04387bfb2d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f20cd4d8a92 - std[1023ab8fe43ea5ab]::panicking::panic_with_hook
   7:     0x7f20cd4ba3f4 - std[1023ab8fe43ea5ab]::panicking::panic_handler::{closure#0}
   8:     0x7f20cd4ae8a9 - std[1023ab8fe43ea5ab]::sys::backtrace::__rust_end_short_backtrace::<std[1023ab8fe43ea5ab]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f20cd4bbd2d - __rustc[46920232926a116e]::rust_begin_unwind
  10:     0x7f20ca5b1a8c - core[ac254214b649f1de]::panicking::panic_fmt
  11:     0x7f20cbe79139 - core[ac254214b649f1de]::num::imp::overflow_panic::sub
  12:     0x7f20ce4cacdb - rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::check_fn_or_method
  13:     0x7f20ce4ce1ea - rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::enter_wf_checking_ctxt::<rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::check_associated_item::{closure#0}>
  14:     0x7f20ceab3f21 - rustc_hir_analysis[6a1607dc5c50ec45]::check::check::check_item_type
  15:     0x7f20ceab03b0 - rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::check_well_formed
  16:     0x7f20ceab0391 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  17:     0x7f20ceaaf971 - rustc_query_impl[e6cc49fff9d6167b]::execution::try_execute_query::<rustc_data_structures[1a2aab4d02078da7]::vec_cache::VecCache<rustc_span[1809dac9b9f9f1f9]::def_id::LocalDefId, rustc_middle[65e93962a5a43da7]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[65e93962a5a43da7]::dep_graph::graph::DepNodeIndex>, false>
  18:     0x7f20ceaaf707 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  19:     0x7f20ceaac1a7 - rustc_hir_analysis[6a1607dc5c50ec45]::check::wfcheck::check_type_wf
  20:     0x7f20ceaac093 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f20ced85186 - rustc_query_impl[e6cc49fff9d6167b]::execution::try_execute_query::<rustc_middle[65e93962a5a43da7]::query::caches::SingleCache<rustc_middle[65e93962a5a43da7]::query::erase::ErasedData<[u8; 1usize]>>, false>
  22:     0x7f20ced84f69 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f20cdfd6b9a - rustc_hir_analysis[6a1607dc5c50ec45]::check_crate
  24:     0x7f20cdfdb1ba - rustc_interface[a6d30ce4ed30ee91]::passes::analysis
  25:     0x7f20ced83707 - rustc_query_impl[e6cc49fff9d6167b]::execution::try_execute_query::<rustc_middle[65e93962a5a43da7]::query::caches::SingleCache<rustc_middle[65e93962a5a43da7]::query::erase::ErasedData<[u8; 0usize]>>, false>
  26:     0x7f20ced83369 - rustc_query_impl[e6cc49fff9d6167b]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f20ced59e40 - rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler::<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}
  28:     0x7f20ced9227a - std[1023ab8fe43ea5ab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_with_globals<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_pool_with_globals<rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x7f20ced9202d - <std[1023ab8fe43ea5ab]::thread::lifecycle::spawn_unchecked<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_with_globals<rustc_interface[a6d30ce4ed30ee91]::util::run_in_thread_pool_with_globals<rustc_interface[a6d30ce4ed30ee91]::interface::run_compiler<(), rustc_driver_impl[cdfcb04387bfb2d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ac254214b649f1de]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7f20ced96450 - <std[1023ab8fe43ea5ab]::sys::thread::unix::Thread>::new::thread_start
  31:     0x7f20c86981b9 - <unknown>
  32:     0x7f20c871d21c - <unknown>
  33:                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: rustc 1.98.0-nightly (ea088e0a3 2026-07-05) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.l0P5vOWzo8Au/rustc_testrunner_tmpdir_reporting.8j2qMBLK2rSD/mvce.rs:1:1: 1:12>::call_once` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 7 previous errors; 1 warning emitted

Some errors have detailed explanations: E0107, E0601, E0658.
For more information about an error, try `rustc --explain E0107`.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-splat`#![feature(splat)]`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions