Skip to content

ICE: delegation: index out of bounds wfcheck #119920

Closed
@matthiaskrgr

Description

@matthiaskrgr

snippet:

trait Trait {
    fn foo(&self) -> u32 { 0 }
}

struct F;

impl Trait for S {
    reuse to_reuse::foo { self }    
    reuse <F as Trait>::foo;
}

Version information

rustc 1.77.0-nightly (89110dafe 2024-01-13)
binary: rustc
commit-hash: 89110dafe79621fa07d6cd7c8493dd1d0a83cfaf
commit-date: 2024-01-13
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

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

Program output

error[E0201]: duplicate definitions with name `foo`:
 --> /tmp/icemaker_global_tempdir.pqDTncwD9B9h/rustc_testrunner_tmpdir_reporting.TJC3bXBXuUGV/mvce.rs:9:5
  |
2 |     fn foo(&self) -> u32 { 0 }
  |     -------------------------- item in trait
...
8 |     reuse to_reuse::foo { self }    
  |     ---------------------------- previous definition here
9 |     reuse <F as Trait>::foo;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition

error[E0412]: cannot find type `S` in this scope
 --> /tmp/icemaker_global_tempdir.pqDTncwD9B9h/rustc_testrunner_tmpdir_reporting.TJC3bXBXuUGV/mvce.rs:7:16
  |
5 | struct F;
  | --------- similarly named struct `F` defined here
6 |
7 | impl Trait for S {
  |                ^ help: a struct with a similar name exists: `F`

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.pqDTncwD9B9h/rustc_testrunner_tmpdir_reporting.TJC3bXBXuUGV/mvce.rs:8:5
  |
8 |     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

error[E0658]: functions delegation is not yet fully implemented
 --> /tmp/icemaker_global_tempdir.pqDTncwD9B9h/rustc_testrunner_tmpdir_reporting.TJC3bXBXuUGV/mvce.rs:9:5
  |
9 |     reuse <F as Trait>::foo;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = 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

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

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/check/wfcheck.rs:1571:16:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7fcb94c207e6 - std::backtrace_rs::backtrace::libunwind::trace::h4f92a9ab1e969130
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fcb94c207e6 - std::backtrace_rs::backtrace::trace_unsynchronized::hff5adbaff3a8cfb8
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fcb94c207e6 - std::sys_common::backtrace::_print_fmt::h9d3e0e63f6f89eaf
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fcb94c207e6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2d31e6c8aa8ef934
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fcb94c72ec0 - core::fmt::rt::Argument::fmt::hd4eaf83b012a42ab
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/fmt/rt.rs:142:9
   5:     0x7fcb94c72ec0 - core::fmt::write::hb507e806b3ae16c4
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fcb94c1414f - std::io::Write::write_fmt::h203bf95b6a67c7a0
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/io/mod.rs:1810:15
   7:     0x7fcb94c205c4 - std::sys_common::backtrace::_print::h2f732cf10966ea1c
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fcb94c205c4 - std::sys_common::backtrace::print::hef45416e244164df
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fcb94c23357 - std::panicking::default_hook::{{closure}}::h1a73802a0a993acf
  10:     0x7fcb94c230b9 - std::panicking::default_hook::h34548737700c4b4d
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:292:9
  11:     0x7fcb9194e80c - std[d6f21989bfff4f42]::panicking::update_hook::<alloc[21b544e6cc75226b]::boxed::Box<rustc_driver_impl[bce72efeea91a1de]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fcb94c23aa6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb0b823449909a650
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/alloc/src/boxed.rs:2030:9
  13:     0x7fcb94c23aa6 - std::panicking::rust_panic_with_hook::h60e4310ab2a16e4e
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:785:13
  14:     0x7fcb94c237f2 - std::panicking::begin_panic_handler::{{closure}}::h61737518028fa2b2
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:659:13
  15:     0x7fcb94c20ce6 - std::sys_common::backtrace::__rust_end_short_backtrace::h7870f48bedce1dac
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fcb94c23550 - rust_begin_unwind
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:647:5
  17:     0x7fcb94c6f5c5 - core::panicking::panic_fmt::h01c3f6a1955aca70
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/panicking.rs:72:14
  18:     0x7fcb94c6f802 - core::panicking::panic_bounds_check::h25b685aaca1db28e
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/panicking.rs:208:5
  19:     0x7fcb9329bc85 - rustc_hir_analysis[f88d56455d931b67]::check::wfcheck::check_associated_item
  20:     0x7fcb933bd4e2 - rustc_hir_analysis[f88d56455d931b67]::check::wfcheck::check_well_formed
  21:     0x7fcb933bc30d - rustc_query_impl[f8b584d7216df600]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f8b584d7216df600]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>
  22:     0x7fcb933bba0b - rustc_query_system[13649e0efc92577a]::query::plumbing::try_execute_query::<rustc_query_impl[f8b584d7216df600]::DynamicConfig<rustc_query_system[13649e0efc92577a]::query::caches::VecCache<rustc_hir[4458c78f2716492d]::hir_id::OwnerId, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f8b584d7216df600]::plumbing::QueryCtxt, false>
  23:     0x7fcb933bb783 - rustc_query_impl[f8b584d7216df600]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7fcb933b92fd - rustc_hir_analysis[f88d56455d931b67]::check::wfcheck::check_mod_type_wf
  25:     0x7fcb933b907b - rustc_query_impl[f8b584d7216df600]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f8b584d7216df600]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>
  26:     0x7fcb933b823b - rustc_query_system[13649e0efc92577a]::query::plumbing::try_execute_query::<rustc_query_impl[f8b584d7216df600]::DynamicConfig<rustc_query_system[13649e0efc92577a]::query::caches::DefaultCache<rustc_span[6e44e330265df079]::def_id::LocalModDefId, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f8b584d7216df600]::plumbing::QueryCtxt, false>
  27:     0x7fcb933b7fd1 - rustc_query_impl[f8b584d7216df600]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7fcb931e9eb0 - <rustc_middle[63813a132a817cd4]::hir::map::Map>::try_par_for_each_module::<rustc_hir_analysis[f88d56455d931b67]::check_crate::{closure#4}::{closure#0}>::{closure#0}
  29:     0x7fcb931e8190 - rustc_hir_analysis[f88d56455d931b67]::check_crate
  30:     0x7fcb93694419 - rustc_interface[37b6cebe1bce16]::passes::analysis
  31:     0x7fcb9369405f - rustc_query_impl[f8b584d7216df600]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f8b584d7216df600]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7fcb93bcd040 - rustc_query_system[13649e0efc92577a]::query::plumbing::try_execute_query::<rustc_query_impl[f8b584d7216df600]::DynamicConfig<rustc_query_system[13649e0efc92577a]::query::caches::SingleCache<rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f8b584d7216df600]::plumbing::QueryCtxt, false>
  33:     0x7fcb93bcce47 - rustc_query_impl[f8b584d7216df600]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7fcb939343ed - rustc_interface[37b6cebe1bce16]::interface::run_compiler::<core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>, rustc_driver_impl[bce72efeea91a1de]::run_compiler::{closure#0}>::{closure#0}
  35:     0x7fcb93bf3546 - std[d6f21989bfff4f42]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[37b6cebe1bce16]::util::run_in_thread_with_globals<rustc_interface[37b6cebe1bce16]::util::run_in_thread_pool_with_globals<rustc_interface[37b6cebe1bce16]::interface::run_compiler<core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>, rustc_driver_impl[bce72efeea91a1de]::run_compiler::{closure#0}>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>
  36:     0x7fcb93bf3373 - <<std[d6f21989bfff4f42]::thread::Builder>::spawn_unchecked_<rustc_interface[37b6cebe1bce16]::util::run_in_thread_with_globals<rustc_interface[37b6cebe1bce16]::util::run_in_thread_pool_with_globals<rustc_interface[37b6cebe1bce16]::interface::run_compiler<core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>, rustc_driver_impl[bce72efeea91a1de]::run_compiler::{closure#0}>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#1} as core[a757d3bbb7cc29b8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7fcb94c2d9d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc62465ce3696edbb
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/alloc/src/boxed.rs:2016:9
  38:     0x7fcb94c2d9d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2898b364df1453ed
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/alloc/src/boxed.rs:2016:9
  39:     0x7fcb94c2d9d5 - std::sys::unix::thread::Thread::new::thread_start::hefe0ce868779f0f1
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys/unix/thread.rs:108:17
  40:     0x7fcb8eaaa9eb - <unknown>
  41:     0x7fcb8eb2e7cc - <unknown>
  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: rustc 1.77.0-nightly (89110dafe 2024-01-13) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.pqDTncwD9B9h/rustc_testrunner_tmpdir_reporting.TJC3bXBXuUGV/mvce.rs:7:1: 7:17>::foo` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error[E0433]: failed to resolve: use of undeclared crate or module `to_reuse`
 --> /tmp/icemaker_global_tempdir.pqDTncwD9B9h/rustc_testrunner_tmpdir_reporting.TJC3bXBXuUGV/mvce.rs:8:11
  |
8 |     reuse to_reuse::foo { self }    
  |           ^^^^^^^^ use of undeclared crate or module `to_reuse`

error: aborting due to 6 previous errors

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

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) ❄️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