Skip to content

ICE: range end index 1 out of range for slice of length 0 #121613

Closed
@matthiaskrgr

Description

auto-reduced (treereduce-rust):

fn main() {
    let _ = <Foo as A>::Assoc { br: 2 };

    let <E>::V(..) = E::V(|a, b| a.cmp(b));
}

struct StructStruct {
    br: i8,
}

struct Foo;

trait A {
    type Assoc;
}

impl A for Foo {
    type Assoc = StructStruct;
}

enum E {
    V(u8),
}

original:

fn main() {
    // destructure through a qualified path
    let <Foo as A>::Assoc { br } = StructStruct { br: 2 };
    //~^ ERROR usage of qualified paths in this context is experimental
    let _ = <Foo as A>::Assoc { br: 2 };
    //~^ ERROR usage of qualified paths in this context is experimental
    let <E>::V(..) = E::V(|a, b| a.cmp(b));
    //~^ ERROR usage of qualified paths in this context is experimental
}

struct StructStruct {
    br: i8,
}

struct Foo;

trait A {
    type Assoc;
}

impl A for Foo {
    type Assoc = StructStruct;
}

enum E {
    V(u8)
}

Version information

rustc 1.78.0-nightly (26cd5d862 2024-02-25)
binary: rustc
commit-hash: 26cd5d862e22c013ecb3396b177d3af80e95c836
commit-date: 2024-02-25
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error[E0658]: usage of qualified paths in this context is experimental
 --> /tmp/icemaker_global_tempdir.9QGrWn4SuYqB/rustc_testrunner_tmpdir_reporting.JmIv37zbqU87/mvce.rs:2:13
  |
2 |     let _ = <Foo as A>::Assoc { br: 2 };
  |             ^^^^^^^^^^^^^^^^^
  |
  = note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information
  = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-25; consider upgrading it if it is out of date

error[E0658]: usage of qualified paths in this context is experimental
 --> /tmp/icemaker_global_tempdir.9QGrWn4SuYqB/rustc_testrunner_tmpdir_reporting.JmIv37zbqU87/mvce.rs:4:9
  |
4 |     let <E>::V(..) = E::V(|a, b| a.cmp(b));
  |         ^^^^^^
  |
  = note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information
  = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-25; consider upgrading it if it is out of date

thread 'rustc' panicked at compiler/rustc_middle/src/ty/generics.rs:360:45:
range end index 1 out of range for slice of length 0
stack backtrace:
   0:     0x7f8c39a78a06 - std::backtrace_rs::backtrace::libunwind::trace::h2b754d54d1bde505
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f8c39a78a06 - std::backtrace_rs::backtrace::trace_unsynchronized::h543e1ca101948fd5
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8c39a78a06 - std::sys_common::backtrace::_print_fmt::h530a113cbf476cc2
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f8c39a78a06 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdaaebae0c7e457dd
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8c39ac998c - core::fmt::rt::Argument::fmt::h986a5c541218a991
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/fmt/rt.rs:142:9
   5:     0x7f8c39ac998c - core::fmt::write::h0480b093981ac277
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f8c39a6d3cf - std::io::Write::write_fmt::he3dd140cfd4aef89
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/io/mod.rs:1846:15
   7:     0x7f8c39a787b4 - std::sys_common::backtrace::_print::hdac374456098a97e
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8c39a787b4 - std::sys_common::backtrace::print::ha7f20ab884506926
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f8c39a7b4fb - std::panicking::default_hook::{{closure}}::h300a405277525f5d
  10:     0x7f8c39a7b249 - std::panicking::default_hook::hde1c193b2da6a81c
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:292:9
  11:     0x7f8c3668892c - std[555420183d371a7f]::panicking::update_hook::<alloc[b9bf11d30073d6dd]::boxed::Box<rustc_driver_impl[633500a3532990b7]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f8c39a7bc60 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h68a9e4d741c266fd
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/alloc/src/boxed.rs:2030:9
  13:     0x7f8c39a7bc60 - std::panicking::rust_panic_with_hook::h8ba518db0741b55a
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:783:13
  14:     0x7f8c39a7b9a2 - std::panicking::begin_panic_handler::{{closure}}::ha55fc9dde68cbcf7
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:657:13
  15:     0x7f8c39a78ee6 - std::sys_common::backtrace::__rust_end_short_backtrace::h6838138199d9ac3e
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f8c39a7b6d4 - rust_begin_unwind
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/panicking.rs:645:5
  17:     0x7f8c39ac5ea5 - core::panicking::panic_fmt::hb9e36ea683b16cf8
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/panicking.rs:72:14
  18:     0x7f8c39acc242 - core::slice::index::slice_end_index_len_fail_rt::hfe2571e0ca7c6ab9
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/slice/index.rs:76:5
  19:     0x7f8c39acc1c6 - core::slice::index::slice_end_index_len_fail::h6cb8a54cb476e1bd
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/core/src/slice/index.rs:68:9
  20:     0x7f8c36b2f0d3 - <rustc_middle[73325823477bd615]::ty::generics::Generics>::own_args
  21:     0x7f8c36974d0f - <rustc_infer[1ff49fd47709a2df]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[1ae7fbfe8e64f62d]::intravisit::Visitor>::visit_expr
  22:     0x7f8c36940535 - <rustc_infer[1ff49fd47709a2df]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[1ae7fbfe8e64f62d]::intravisit::Visitor>::visit_local
  23:     0x7f8c3692cdf2 - <rustc_infer[1ff49fd47709a2df]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[1ae7fbfe8e64f62d]::intravisit::Visitor>::visit_block
  24:     0x7f8c36975467 - <rustc_infer[1ff49fd47709a2df]::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir[1ae7fbfe8e64f62d]::intravisit::Visitor>::visit_expr
  25:     0x7f8c369727d2 - <rustc_infer[1ff49fd47709a2df]::infer::error_reporting::TypeErrCtxt>::emit_inference_failure_err
  26:     0x7f8c3849e5ed - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27:     0x7f8c382f8a08 - rustc_hir_typeck[2ba3259e05449eae]::check::check_fn
  28:     0x7f8c384095e2 - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_expr_closure
  29:     0x7f8c3849711d - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7f8c3853db52 - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_argument_types
  31:     0x7f8c382c6947 - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_call
  32:     0x7f8c384944e3 - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33:     0x7f8c37ed896a - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_decl
  34:     0x7f8c37fa774d - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_block_with_expected
  35:     0x7f8c384949c6 - <rustc_hir_typeck[2ba3259e05449eae]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36:     0x7f8c382f8a08 - rustc_hir_typeck[2ba3259e05449eae]::check::check_fn
  37:     0x7f8c37b406ad - rustc_hir_typeck[2ba3259e05449eae]::typeck
  38:     0x7f8c37b3f98b - rustc_query_impl[2c9e1b0525c9d953]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2c9e1b0525c9d953]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[73325823477bd615]::query::erase::Erased<[u8; 8usize]>>
  39:     0x7f8c37d0e570 - rustc_query_system[dfd6c8aac03f3724]::query::plumbing::try_execute_query::<rustc_query_impl[2c9e1b0525c9d953]::DynamicConfig<rustc_query_system[dfd6c8aac03f3724]::query::caches::VecCache<rustc_span[dc6b5ece0d38defd]::def_id::LocalDefId, rustc_middle[73325823477bd615]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2c9e1b0525c9d953]::plumbing::QueryCtxt, false>
  40:     0x7f8c37d0e08c - rustc_query_impl[2c9e1b0525c9d953]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f8c383cd4d2 - <rustc_middle[73325823477bd615]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[7c1425229e6d6e04]::check_crate::{closure#6}>::{closure#0}
  42:     0x7f8c383cbd9d - rustc_hir_analysis[7c1425229e6d6e04]::check_crate
  43:     0x7f8c386059af - rustc_interface[27abfdff6e6b27c2]::passes::analysis
  44:     0x7f8c38605619 - rustc_query_impl[2c9e1b0525c9d953]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2c9e1b0525c9d953]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[73325823477bd615]::query::erase::Erased<[u8; 1usize]>>
  45:     0x7f8c3871f8e5 - rustc_query_system[dfd6c8aac03f3724]::query::plumbing::try_execute_query::<rustc_query_impl[2c9e1b0525c9d953]::DynamicConfig<rustc_query_system[dfd6c8aac03f3724]::query::caches::SingleCache<rustc_middle[73325823477bd615]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[2c9e1b0525c9d953]::plumbing::QueryCtxt, false>
  46:     0x7f8c3871f649 - rustc_query_impl[2c9e1b0525c9d953]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  47:     0x7f8c3872eb16 - rustc_interface[27abfdff6e6b27c2]::interface::run_compiler::<core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>, rustc_driver_impl[633500a3532990b7]::run_compiler::{closure#0}>::{closure#0}
  48:     0x7f8c389c8cc5 - std[555420183d371a7f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[27abfdff6e6b27c2]::util::run_in_thread_with_globals<rustc_interface[27abfdff6e6b27c2]::util::run_in_thread_pool_with_globals<rustc_interface[27abfdff6e6b27c2]::interface::run_compiler<core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>, rustc_driver_impl[633500a3532990b7]::run_compiler::{closure#0}>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>
  49:     0x7f8c389c8af2 - <<std[555420183d371a7f]::thread::Builder>::spawn_unchecked_<rustc_interface[27abfdff6e6b27c2]::util::run_in_thread_with_globals<rustc_interface[27abfdff6e6b27c2]::util::run_in_thread_pool_with_globals<rustc_interface[27abfdff6e6b27c2]::interface::run_compiler<core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>, rustc_driver_impl[633500a3532990b7]::run_compiler::{closure#0}>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[421030ac42e8f54b]::result::Result<(), rustc_span[dc6b5ece0d38defd]::ErrorGuaranteed>>::{closure#1} as core[421030ac42e8f54b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x7f8c39a85635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h176656733d324092
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/alloc/src/boxed.rs:2016:9
  51:     0x7f8c39a85635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2cb067df8c4b40c7
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/alloc/src/boxed.rs:2016:9
  52:     0x7f8c39a85635 - std::sys::pal::unix::thread::Thread::new::thread_start::h9c4fa792b58c770f
                               at /rustc/26cd5d862e22c013ecb3396b177d3af80e95c836/library/std/src/sys/pal/unix/thread.rs:108:17
  53:     0x7f8c336a955a - <unknown>
  54:     0x7f8c33726a3c - <unknown>
  55:                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.78.0-nightly (26cd5d862 2024-02-25) running on x86_64-unknown-linux-gnu

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-HIRArea: The high-level intermediate representation (HIR)C-bugCategory: This is a bug.F-more_qualified_paths`#![feature(more_qualified_paths)]`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