Skip to content

ICE: fn_ctxt: index out of bounds #128848

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait A<T> {}

fn f<T, U, V: A<T>>(i: V, arena: T, k: U) -> (T, U) {
    f.call_once(j, k)
}

original:

trait A<T> {
    fn g<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
}

impl From<I> for i32 { }
impl<EncodedValue> A<T> for u32 { }

fn f<T, U, V: A<T>>(i: V, arena: T, k: U) -> (T, U) {
    f.call_once(j, k)
}

pub fn main () {
    assert_eq!(f(0, 1, 2), (1, 2));
    assert_eq!(f(0, 1, 2), (1, 2));
}

Version information

rustc 1.82.0-nightly (2048386fe 2024-08-08)
binary: rustc
commit-hash: 2048386fe2898febe7315c0feb915458e41c7aa5
commit-date: 2024-08-08
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

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

Program output

error[E0425]: cannot find value `j` in this scope
 --> /tmp/icemaker_global_tempdir.GCP2eBzpwgpY/rustc_testrunner_tmpdir_reporting.asPRKVXEGOYI/mvce.rs:4:17
  |
4 |     f.call_once(j, k)
  |                 ^ not found in this scope

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.GCP2eBzpwgpY/rustc_testrunner_tmpdir_reporting.asPRKVXEGOYI/mvce.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.GCP2eBzpwgpY/rustc_testrunner_tmpdir_reporting.asPRKVXEGOYI/mvce.rs`

error[E0658]: use of unstable library feature 'fn_traits'
 --> /tmp/icemaker_global_tempdir.GCP2eBzpwgpY/rustc_testrunner_tmpdir_reporting.asPRKVXEGOYI/mvce.rs:4:7
  |
4 |     f.call_once(j, k)
  |       ^^^^^^^^^
  |
  = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
  = help: add `#![feature(fn_traits)]` to the crate attributes to enable
  = note: this compiler was built on 2024-08-08; consider upgrading it if it is out of date

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs:2289:46:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
   0:     0x7e97171eab0d - std::backtrace_rs::backtrace::libunwind::trace::h288a87c5e2679186
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7e97171eab0d - std::backtrace_rs::backtrace::trace_unsynchronized::h5284ad94e8c74688
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7e97171eab0d - std::sys::backtrace::_print_fmt::h371adc3f02dab1dd
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/sys/backtrace.rs:66:9
   3:     0x7e97171eab0d - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h148e7d8e87bab30f
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/sys/backtrace.rs:39:26
   4:     0x7e971723b29b - core::fmt::rt::Argument::fmt::h7d54e75d5909de1b
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/core/src/fmt/rt.rs:173:76
   5:     0x7e971723b29b - core::fmt::write::hf6482455a45a91c7
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/core/src/fmt/mod.rs:1178:21
   6:     0x7e97171de9a3 - std::io::Write::write_fmt::h78337f43013967dc
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/io/mod.rs:1823:15
   7:     0x7e97171ed302 - std::sys::backtrace::BacktraceLock::print::he76ad41bfebe12ae
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/sys/backtrace.rs:42:9
   8:     0x7e97171ed302 - std::panicking::default_hook::{{closure}}::hea2fb4697dfb5a9e
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/panicking.rs:266:22
   9:     0x7e97171ecf6e - std::panicking::default_hook::h1dd19741d2e30ca9
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/panicking.rs:293:9
  10:     0x7e97136ba397 - std[3ddd7f8965915055]::panicking::update_hook::<alloc[5625efa5c1f04643]::boxed::Box<rustc_driver_impl[a075302d1f094aad]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x7e97171edcf2 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0b220dc3792e0071
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/alloc/src/boxed.rs:2164:9
  12:     0x7e97171edcf2 - std::panicking::rust_panic_with_hook::h31e66c1e0f0e6e18
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/panicking.rs:805:13
  13:     0x7e97171ed9a7 - std::panicking::begin_panic_handler::{{closure}}::h1057116e4a630d6a
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/panicking.rs:671:13
  14:     0x7e97171eaff9 - std::sys::backtrace::__rust_end_short_backtrace::h943392b86d4267f1
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/sys/backtrace.rs:170:18
  15:     0x7e97171ed634 - rust_begin_unwind
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/panicking.rs:662:5
  16:     0x7e97172378f3 - core::panicking::panic_fmt::h8f072a14c223852d
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/core/src/panicking.rs:74:14
  17:     0x7e9717237ae7 - core::panicking::panic_bounds_check::he6402fc016b56f3d
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/core/src/panicking.rs:276:5
  18:     0x7e97139cf86a - <rustc_hir_typeck[dc91aa33eceb2355]::fn_ctxt::FnCtxt>::label_fn_like
  19:     0x7e97139c7356 - <rustc_hir_typeck[dc91aa33eceb2355]::fn_ctxt::FnCtxt>::report_arg_errors
  20:     0x7e97114bd534 - <rustc_hir_typeck[dc91aa33eceb2355]::fn_ctxt::FnCtxt>::check_method_argument_types
  21:     0x7e971550403c - <rustc_hir_typeck[dc91aa33eceb2355]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:     0x7e97154fba4b - <rustc_hir_typeck[dc91aa33eceb2355]::fn_ctxt::FnCtxt>::check_block_with_expected
  23:     0x7e97155032d8 - <rustc_hir_typeck[dc91aa33eceb2355]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x7e97154de180 - rustc_hir_typeck[dc91aa33eceb2355]::check::check_fn
  25:     0x7e97154c08f7 - rustc_hir_typeck[dc91aa33eceb2355]::typeck
  26:     0x7e97154c02b3 - rustc_query_impl[d0e7c8c52ee208c5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d0e7c8c52ee208c5]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d6a66d085659a7e0]::query::erase::Erased<[u8; 8usize]>>
  27:     0x7e9714f633f5 - rustc_query_system[bcd77f19768ca8fb]::query::plumbing::try_execute_query::<rustc_query_impl[d0e7c8c52ee208c5]::DynamicConfig<rustc_query_system[bcd77f19768ca8fb]::query::caches::VecCache<rustc_span[d8ab92baa90519c6]::def_id::LocalDefId, rustc_middle[d6a66d085659a7e0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[d0e7c8c52ee208c5]::plumbing::QueryCtxt, false>
  28:     0x7e9714f625e3 - rustc_query_impl[d0e7c8c52ee208c5]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7e9714f62200 - <rustc_middle[d6a66d085659a7e0]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[f363d87ce7e00737]::check_crate::{closure#4}>::{closure#0}
  30:     0x7e9714f5ffec - rustc_hir_analysis[f363d87ce7e00737]::check_crate
  31:     0x7e9714f55995 - rustc_interface[ecbe5e558f1e13b6]::passes::analysis
  32:     0x7e9714f55547 - rustc_query_impl[d0e7c8c52ee208c5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d0e7c8c52ee208c5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d6a66d085659a7e0]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7e9715be502e - rustc_query_system[bcd77f19768ca8fb]::query::plumbing::try_execute_query::<rustc_query_impl[d0e7c8c52ee208c5]::DynamicConfig<rustc_query_system[bcd77f19768ca8fb]::query::caches::SingleCache<rustc_middle[d6a66d085659a7e0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[d0e7c8c52ee208c5]::plumbing::QueryCtxt, false>
  34:     0x7e9715be4d8f - rustc_query_impl[d0e7c8c52ee208c5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7e9715a5d260 - rustc_interface[ecbe5e558f1e13b6]::interface::run_compiler::<core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>, rustc_driver_impl[a075302d1f094aad]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7e971596a489 - std[3ddd7f8965915055]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ecbe5e558f1e13b6]::util::run_in_thread_with_globals<rustc_interface[ecbe5e558f1e13b6]::util::run_in_thread_pool_with_globals<rustc_interface[ecbe5e558f1e13b6]::interface::run_compiler<core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>, rustc_driver_impl[a075302d1f094aad]::run_compiler::{closure#0}>::{closure#1}, core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>>::{closure#0}, core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>>
  37:     0x7e971596a232 - <<std[3ddd7f8965915055]::thread::Builder>::spawn_unchecked_<rustc_interface[ecbe5e558f1e13b6]::util::run_in_thread_with_globals<rustc_interface[ecbe5e558f1e13b6]::util::run_in_thread_pool_with_globals<rustc_interface[ecbe5e558f1e13b6]::interface::run_compiler<core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>, rustc_driver_impl[a075302d1f094aad]::run_compiler::{closure#0}>::{closure#1}, core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>>::{closure#0}, core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d8d378ef57b379bb]::result::Result<(), rustc_span[d8ab92baa90519c6]::ErrorGuaranteed>>::{closure#1} as core[d8d378ef57b379bb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7e97171f7a0b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8531124d63bf03d4
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/alloc/src/boxed.rs:2150:9
  39:     0x7e97171f7a0b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h14280c2e7cc937ab
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/alloc/src/boxed.rs:2150:9
  40:     0x7e97171f7a0b - std::sys::pal::unix::thread::Thread::new::thread_start::hfbbba69bca48c3db
                               at /rustc/2048386fe2898febe7315c0feb915458e41c7aa5/library/std/src/sys/pal/unix/thread.rs:110:17
  41:     0x7e97100a6ded - <unknown>
  42:     0x7e971012a0dc - <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: please make sure that you have updated to the latest nightly

note: rustc 1.82.0-nightly (2048386fe 2024-08-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `f`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions