Skip to content

ICE: delegation: index out of bounds #128119

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait {
    reuse to_reuse::foo { self }
}


struct S;

mod to_reuse {
    pub fn foo(&self) -> u32 {}
}

impl Trait  S {
    reuse to_reuse::foo { self }
}

original:

trait Trait {
    reuse to_reuse::foo { self }
}

struct Trait;
struct S;

mod to_reuse {
    pub fn foo(&self) -> u32 {}
}

impl Trait  S {
    reuse to_reuse::foo { self }
}

Version information

rustc 1.82.0-nightly (84c257ebe 2024-07-23)
binary: rustc
commit-hash: 84c257ebe5319ba68ce9a4ce5bca2d89e7127a14
commit-date: 2024-07-23
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 18.1.7

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

Program output

error: missing `for` in a trait impl
  --> /tmp/icemaker_global_tempdir.HWU1MVIGLwj9/rustc_testrunner_tmpdir_reporting.x2Si1gLufU2j/mvce.rs:12:11
   |
12 | impl Trait  S {
   |           ^^
   |
help: add `for` here
   |
12 | impl Trait for S {
   |            +++

error: `self` parameter is only allowed in associated functions
 --> /tmp/icemaker_global_tempdir.HWU1MVIGLwj9/rustc_testrunner_tmpdir_reporting.x2Si1gLufU2j/mvce.rs:9:16
  |
9 |     pub fn foo(&self) -> u32 {}
  |                ^^^^^ not semantically valid as function parameter
  |
  = note: associated functions are those in `impl` or `trait` definitions

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.HWU1MVIGLwj9/rustc_testrunner_tmpdir_reporting.x2Si1gLufU2j/mvce.rs:2:5
  |
2 |     reuse to_reuse::foo { self }
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
  = note: this compiler was built on 2024-07-23; consider upgrading it if it is out of date

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.HWU1MVIGLwj9/rustc_testrunner_tmpdir_reporting.x2Si1gLufU2j/mvce.rs:13:5
   |
13 |     reuse to_reuse::foo { self }
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable
   = note: this compiler was built on 2024-07-23; consider upgrading it if it is out of date

thread 'rustc' panicked at compiler/rustc_ast_lowering/src/delegation.rs:334:59:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x724bccc77215 - std::backtrace_rs::backtrace::libunwind::trace::h079c5b10617d341d
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x724bccc77215 - std::backtrace_rs::backtrace::trace_unsynchronized::hd7f004a4c1ba9b08
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x724bccc77215 - std::sys::backtrace::_print_fmt::hc9fcd7a583f53d0e
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/sys/backtrace.rs:68:9
   3:     0x724bccc77215 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h0fa110c20a9e6b9b
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/sys/backtrace.rs:41:26
   4:     0x724bcccc6c8b - core::fmt::rt::Argument::fmt::h2fa86b20e267917d
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/core/src/fmt/rt.rs:173:76
   5:     0x724bcccc6c8b - core::fmt::write::hc0abd2b87c9c9f9b
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/core/src/fmt/mod.rs:1182:21
   6:     0x724bccc6bcef - std::io::Write::write_fmt::h0eab51fe5cc04d2d
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/io/mod.rs:1827:15
   7:     0x724bccc79a01 - std::sys::backtrace::BacktraceLock::print::h73f7904e8c6470c5
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/sys/backtrace.rs:44:9
   8:     0x724bccc79a01 - std::panicking::default_hook::{{closure}}::h5772adf9111786bd
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/panicking.rs:269:22
   9:     0x724bccc796dc - std::panicking::default_hook::h96e37809c3d46f88
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/panicking.rs:296:9
  10:     0x724bc90255e9 - std[5c22d0894761bf95]::panicking::update_hook::<alloc[e548e83657ed7a36]::boxed::Box<rustc_driver_impl[e0a91da34026eb19]::install_ice_hook::{closure#0}>>::{closure#0}
  11:     0x724bccc7a3cf - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h20dc0ffe6bab5b1c
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/alloc/src/boxed.rs:2163:9
  12:     0x724bccc7a3cf - std::panicking::rust_panic_with_hook::h8e39c57c8213f108
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/panicking.rs:808:13
  13:     0x724bccc79ff7 - std::panicking::begin_panic_handler::{{closure}}::h3bced104df636721
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/panicking.rs:674:13
  14:     0x724bccc776d9 - std::sys::backtrace::__rust_end_short_backtrace::hd2ecf03e595ba397
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/sys/backtrace.rs:172:18
  15:     0x724bccc79c84 - rust_begin_unwind
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/panicking.rs:665:5
  16:     0x724bcccc3243 - core::panicking::panic_fmt::h035bf8637e3dbe4b
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/core/src/panicking.rs:74:14
  17:     0x724bcccc3437 - core::panicking::panic_bounds_check::h14e13ffb87f2f714
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/core/src/panicking.rs:276:5
  18:     0x724bc8c39e3f - <rustc_ast_lowering[7fcdca43ed366bd6]::LoweringContext>::lower_delegation
  19:     0x724bcacf1694 - <rustc_ast_lowering[7fcdca43ed366bd6]::LoweringContext>::lower_assoc_item
  20:     0x724bcace1006 - <rustc_ast_lowering[7fcdca43ed366bd6]::item::ItemLowerer>::lower_node
  21:     0x724bcacddd39 - rustc_ast_lowering[7fcdca43ed366bd6]::lower_to_hir
  22:     0x724bcb4eb020 - rustc_query_impl[1c27faad8f8c2359]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1c27faad8f8c2359]::query_impl::hir_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 8usize]>>
  23:     0x724bcb4e80c2 - rustc_query_system[e65aa676d33ec03e]::query::plumbing::try_execute_query::<rustc_query_impl[1c27faad8f8c2359]::DynamicConfig<rustc_query_system[e65aa676d33ec03e]::query::caches::SingleCache<rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1c27faad8f8c2359]::plumbing::QueryCtxt, false>
  24:     0x724bcb4e7d5e - rustc_query_impl[1c27faad8f8c2359]::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
  25:     0x724bcae9f3a4 - rustc_query_impl[1c27faad8f8c2359]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1c27faad8f8c2359]::query_impl::hir_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 8usize]>>
  26:     0x724bcae9e95f - rustc_query_system[e65aa676d33ec03e]::query::plumbing::try_execute_query::<rustc_query_impl[1c27faad8f8c2359]::DynamicConfig<rustc_query_system[e65aa676d33ec03e]::query::caches::VecCache<rustc_hir[b042a47ad172a40e]::hir_id::OwnerId, rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1c27faad8f8c2359]::plumbing::QueryCtxt, false>
  27:     0x724bcae9e6cf - rustc_query_impl[1c27faad8f8c2359]::query_impl::hir_attrs::get_query_non_incr::__rust_end_short_backtrace
  28:     0x724bca83cd86 - <rustc_middle[d55bccc9e833afb]::hir::map::Map>::attrs
  29:     0x724bcb5f13c1 - rustc_passes[87d8bc38134e89b]::entry::entry_fn
  30:     0x724bcb5f1358 - rustc_query_impl[1c27faad8f8c2359]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1c27faad8f8c2359]::query_impl::entry_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 12usize]>>
  31:     0x724bcb5f132f - <rustc_query_impl[1c27faad8f8c2359]::query_impl::entry_fn::dynamic_query::{closure#2} as core[b11752a00712c889]::ops::function::FnOnce<(rustc_middle[d55bccc9e833afb]::ty::context::TyCtxt, ())>>::call_once
  32:     0x724bcb5f0c48 - rustc_query_system[e65aa676d33ec03e]::query::plumbing::try_execute_query::<rustc_query_impl[1c27faad8f8c2359]::DynamicConfig<rustc_query_system[e65aa676d33ec03e]::query::caches::SingleCache<rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 12usize]>>, false, false, false>, rustc_query_impl[1c27faad8f8c2359]::plumbing::QueryCtxt, false>
  33:     0x724bcb5f09fd - rustc_query_impl[1c27faad8f8c2359]::query_impl::entry_fn::get_query_non_incr::__rust_end_short_backtrace
  34:     0x724bcae76132 - rustc_interface[ca1eba3031847acc]::passes::analysis
  35:     0x724bcae75f5b - rustc_query_impl[1c27faad8f8c2359]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1c27faad8f8c2359]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 1usize]>>
  36:     0x724bcb4e94e5 - rustc_query_system[e65aa676d33ec03e]::query::plumbing::try_execute_query::<rustc_query_impl[1c27faad8f8c2359]::DynamicConfig<rustc_query_system[e65aa676d33ec03e]::query::caches::SingleCache<rustc_middle[d55bccc9e833afb]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1c27faad8f8c2359]::plumbing::QueryCtxt, false>
  37:     0x724bcb4e924f - rustc_query_impl[1c27faad8f8c2359]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x724bcb3e2bc5 - rustc_interface[ca1eba3031847acc]::interface::run_compiler::<core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>, rustc_driver_impl[e0a91da34026eb19]::run_compiler::{closure#0}>::{closure#1}
  39:     0x724bcb3c8349 - std[5c22d0894761bf95]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ca1eba3031847acc]::util::run_in_thread_with_globals<rustc_interface[ca1eba3031847acc]::util::run_in_thread_pool_with_globals<rustc_interface[ca1eba3031847acc]::interface::run_compiler<core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>, rustc_driver_impl[e0a91da34026eb19]::run_compiler::{closure#0}>::{closure#1}, core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>>::{closure#0}, core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>>
  40:     0x724bcb3c80fa - <<std[5c22d0894761bf95]::thread::Builder>::spawn_unchecked_<rustc_interface[ca1eba3031847acc]::util::run_in_thread_with_globals<rustc_interface[ca1eba3031847acc]::util::run_in_thread_pool_with_globals<rustc_interface[ca1eba3031847acc]::interface::run_compiler<core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>, rustc_driver_impl[e0a91da34026eb19]::run_compiler::{closure#0}>::{closure#1}, core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>>::{closure#0}, core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b11752a00712c889]::result::Result<(), rustc_span[5510ed7e96d6ad1b]::ErrorGuaranteed>>::{closure#1} as core[b11752a00712c889]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x724bccc8442b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha48d6c8806b72121
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/alloc/src/boxed.rs:2149:9
  42:     0x724bccc8442b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::heb92897a6cf54248
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/alloc/src/boxed.rs:2149:9
  43:     0x724bccc8442b - std::sys::pal::unix::thread::Thread::new::thread_start::hb52b315b33e9d801
                               at /rustc/84c257ebe5319ba68ce9a4ce5bca2d89e7127a14/library/std/src/sys/pal/unix/thread.rs:108:17
  44:     0x724bcca18ded - <unknown>
  45:     0x724bcca9c0dc - <unknown>
  46:                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 (84c257ebe 2024-07-23) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [hir_crate] getting the crate HIR
#1 [hir_attrs] getting HIR owner attributes in ``
end of query stack
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0658`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-fn_delegation`#![feature(fn_delegation)]`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.T-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