Skip to content

[ICE]: index out of bounds: the len is 0 but the index is .. #160800

Description

@matthiaskrgr

Code

#![feature(type_alias_impl_trait)]
type Foo = impl Send;

struct A;

#[define_opaque(Foo)]
const VALUE: Foo = todo!();

#[define_opaque(Foo)]
fn test(foo: Foo) {
    match VALUE {
        &mut Some(ref mut x) => *x,
        &mut None => panic!(),
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (771916f90 2026-08-08)
binary: rustc
commit-hash: 771916f9028e7fe56d2685f2c4f698de5d7d6a45
commit-date: 2026-08-08
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0

Error output

error: item does not constrain `Foo::{opaque#0}`
 --> code.rs:7:7
  |
7 | const VALUE: Foo = todo!();
  |       ^^^^^
  |
  = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
note: this opaque type is supposed to be constrained
 --> code.rs:2:12
  |
2 | type Foo = impl Send;
  |            ^^^^^^^^^

warning: unused variable: `foo`
  --> code.rs:10:9
   |
10 | fn test(foo: Foo) {
   |         ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

Backtrace

thread 'rustc' (3960277) panicked at /rustc-dev/771916f9028e7fe56d2685f2c4f698de5d7d6a45/compiler/rustc_mir_dataflow/src/un_derefer.rs:67:20:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f174d70d2b6 - <<std[d336e1aa20b017e8]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f3eec57d7c5a5c99]::fmt::Display>::fmt
   1:     0x7f174de11c8f - core[f3eec57d7c5a5c99]::fmt::write
   2:     0x7f174d7221dc - <std[d336e1aa20b017e8]::sys::stdio::unix::Stderr as core[f3eec57d7c5a5c99]::io::write::Write>::write_fmt
   3:     0x7f174d6e032a - std[d336e1aa20b017e8]::panicking::default_hook::{closure#0}
   4:     0x7f174d701043 - std[d336e1aa20b017e8]::panicking::default_hook
   5:     0x7f174c65beda - std[d336e1aa20b017e8]::panicking::update_hook::<alloc[a6218fca04c82945]::boxed::Box<rustc_driver_impl[7956faa26824032a]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f174d7014e2 - std[d336e1aa20b017e8]::panicking::panic_with_hook
   7:     0x7f174d6e03e2 - std[d336e1aa20b017e8]::panicking::panic_handler::{closure#0}
   8:     0x7f174d6d92b9 - std[d336e1aa20b017e8]::sys::backtrace::__rust_end_short_backtrace::<std[d336e1aa20b017e8]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f174d6e1dbd - __rustc[9438f7ed0802b081]::rust_begin_unwind
  10:     0x7f174a37f46c - core[f3eec57d7c5a5c99]::panicking::panic_fmt
  11:     0x7f174ae5c154 - core[f3eec57d7c5a5c99]::panicking::panic_bounds_check
  12:     0x7f174a14767a - <rustc_mir_dataflow[69773cb1756060d8]::impls::initialized::MaybeInitializedPlaces as rustc_mir_dataflow[69773cb1756060d8]::framework::Analysis>::iterate_to_fixpoint
  13:     0x7f174a16761d - <rustc_mir_transform[28b060d57b516d55]::elaborate_drops::ElaborateDrops as rustc_mir_transform[28b060d57b516d55]::pass_manager::MirPass>::run_pass
  14:     0x7f174de17de2 - rustc_mir_transform[28b060d57b516d55]::run_analysis_to_runtime_passes
  15:     0x7f174e4d0717 - rustc_mir_transform[28b060d57b516d55]::mir_drops_elaborated_and_const_checked
  16:     0x7f174e4d38f5 - rustc_query_impl[f2c47540efc44da2]::execution::try_execute_query::<rustc_data_structures[47e0eddda0e0a292]::vec_cache::VecCache<rustc_span[5a330e2a527940b1]::def_id::LocalDefId, rustc_middle[78cd89ce21bdaa52]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[78cd89ce21bdaa52]::dep_graph::graph::DepNodeIndex>, false>
  17:     0x7f174e4d3103 - rustc_query_impl[f2c47540efc44da2]::query_impl::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7f174e4d622a - <rustc_middle[78cd89ce21bdaa52]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[fca7d0b553b989d0]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  19:     0x7f174e4d533e - rustc_interface[fca7d0b553b989d0]::passes::analysis
  20:     0x7f174efa808a - rustc_query_impl[f2c47540efc44da2]::execution::try_execute_query::<rustc_middle[78cd89ce21bdaa52]::query::caches::SingleCache<rustc_middle[78cd89ce21bdaa52]::query::erase::ErasedData<[u8; 0usize]>>, false>
  21:     0x7f174efa7cff - rustc_query_impl[f2c47540efc44da2]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7f174f02cb35 - rustc_interface[fca7d0b553b989d0]::interface::run_compiler::<(), rustc_driver_impl[7956faa26824032a]::run_compiler::{closure#0}>::{closure#2}
  23:     0x7f174f06d424 - std[d336e1aa20b017e8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[fca7d0b553b989d0]::util::run_in_thread_with_globals<rustc_interface[fca7d0b553b989d0]::util::run_in_thread_pool_with_globals<rustc_interface[fca7d0b553b989d0]::interface::run_compiler<(), rustc_driver_impl[7956faa26824032a]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:     0x7f174f06d1ed - <std[d336e1aa20b017e8]::thread::lifecycle::spawn_unchecked<rustc_interface[fca7d0b553b989d0]::util::run_in_thread_with_globals<rustc_interface[fca7d0b553b989d0]::util::run_in_thread_pool_with_globals<rustc_interface[fca7d0b553b989d0]::interface::run_compiler<(), rustc_driver_impl[7956faa26824032a]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f3eec57d7c5a5c99]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f174f0a56ba - <std[d336e1aa20b017e8]::sys::thread::unix::Thread>::new::thread_start
  26:     0x7f1748497739 - <unknown>
  27:     0x7f174851bedc - <unknown>
  28:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-08-09T10_49_26-3960267.txt` to your bug report

note: rustc 1.99.0-nightly (771916f90 2026-08-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `test`
#1 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions