Skip to content

[ICE]: fulfillment_errors: index out of bounds: the len is 1 but the index is 1 #152518

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
fn check<T: Iterator, U: ?Sized>() {
    <f32 as From<<T as Iterator>::Item>>::from;
}

original:

use std::mem;

struct Misc<T:?Sized>(T);

fn check<T: Iterator, U: ?Sized>() {
    // suggest a where-clause, if needed
    mem::size_of::<U>();
    //~^ ERROR the size for values of type

    mem::size_of::<Misc<U>>();
    //~^ ERROR the size for values of type

    // ... even if T occurs as a type parameter

    <u64 as From<T>>::from;
    //~^ ERROR `u64: From<T>` is not satisfied

    <f32 as From<<T as Iterator>::Item>>::from;
    //~^ ERROR `u64: From<<T as Iterator>::Item>` is not satisfied

    // ... but not if there are inference variables

    <Misc<_> as From<T>>::from;
    //~^ ERROR `Misc<_>: From<T>` is not satisfied

    // ... and also not if the error is not related to the type

    mem::size_of::<[T]>();
    //~^ ERROR the size for values of type

    mem::size_of::<[&U]>();
    //~^ ERROR the size for values of type
}

fn main() {
}

Version information

rustc 1.95.0-nightly (5fdff787e 2026-02-11)
binary: rustc
commit-hash: 5fdff787e6ef7cd4458f81e69cbb4d2a39439a98
commit-date: 2026-02-11
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Possibly related line of code:

let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg);
let trait_def_id = main_trait_predicate.def_id();
if self.tcx.is_diagnostic_item(sym::From, trait_def_id)
|| self.tcx.is_diagnostic_item(sym::TryFrom, trait_def_id)
{
let found_ty = leaf_trait_predicate.skip_binder().trait_ref.args.type_at(1);
let ty = main_trait_predicate.skip_binder().self_ty();
if let Some(cast_ty) = self.find_explicit_cast_type(
obligation.param_env,
found_ty,
ty,
) {

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

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


thread 'rustc' (3060533) panicked at /rustc-dev/5fdff787e6ef7cd4458f81e69cbb4d2a39439a98/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:285:94:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
   0:     0x7f9924176f8b - <<std[3caa9718c767cdb0]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[6fc5908a1b7800da]::fmt::Display>::fmt
   1:     0x7f99248110c8 - core[6fc5908a1b7800da]::fmt::write
   2:     0x7f992418e206 - <std[3caa9718c767cdb0]::sys::stdio::unix::Stderr as std[3caa9718c767cdb0]::io::Write>::write_fmt
   3:     0x7f992414d038 - std[3caa9718c767cdb0]::panicking::default_hook::{closure#0}
   4:     0x7f992416a3f3 - std[3caa9718c767cdb0]::panicking::default_hook
   5:     0x7f992314df3f - std[3caa9718c767cdb0]::panicking::update_hook::<alloc[9583f8edfca66464]::boxed::Box<rustc_driver_impl[286b0c75f16868d8]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f992416a6d2 - std[3caa9718c767cdb0]::panicking::panic_with_hook
   7:     0x7f992414d0f8 - std[3caa9718c767cdb0]::panicking::panic_handler::{closure#0}
   8:     0x7f9924141669 - std[3caa9718c767cdb0]::sys::backtrace::__rust_end_short_backtrace::<std[3caa9718c767cdb0]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f992414eb5d - __rustc[8ac5850bec2b1b43]::rust_begin_unwind
  10:     0x7f992136250c - core[6fc5908a1b7800da]::panicking::panic_fmt
  11:     0x7f99210b7bb2 - core[6fc5908a1b7800da]::panicking::panic_bounds_check
  12:     0x7f9923f4bab7 - <rustc_trait_selection[65ded98220095557]::error_reporting::TypeErrCtxt>::report_selection_error
  13:     0x7f9922a56786 - <rustc_trait_selection[65ded98220095557]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  14:     0x7f992561a50b - rustc_hir_typeck[da107f2967ad6f18]::typeck_with_inspect::{closure#0}
  15:     0x7f9925610572 - rustc_query_impl[f150d155ff7d55dc]::query_impl::typeck::compute_fn::__rust_begin_short_backtrace
  16:     0x7f99251723fe - rustc_query_impl[f150d155ff7d55dc]::execution::try_execute_query::<rustc_data_structures[ad856ab7d49c9531]::vec_cache::VecCache<rustc_span[41ced7df3c66d6ec]::def_id::LocalDefId, rustc_middle[c35976215db85e11]::query::erase::ErasedData<[u8; 8usize]>, rustc_query_system[de015fc87cde175b]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[f150d155ff7d55dc]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  17:     0x7f9925171fc9 - rustc_query_impl[f150d155ff7d55dc]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  18:     0x7f9925169d46 - <rustc_middle[c35976215db85e11]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[8e76de9bc6055e4d]::check_crate::{closure#2}>::{closure#0}
  19:     0x7f9925169777 - rustc_hir_analysis[8e76de9bc6055e4d]::check_crate
  20:     0x7f992516d799 - rustc_interface[6aac31471fbf89a2]::passes::analysis
  21:     0x7f9925a3eff8 - rustc_query_impl[f150d155ff7d55dc]::execution::try_execute_query::<rustc_query_system[de015fc87cde175b]::query::caches::SingleCache<rustc_middle[c35976215db85e11]::query::erase::ErasedData<[u8; 0usize]>>, {rustc_query_impl[f150d155ff7d55dc]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  22:     0x7f9925a3edce - rustc_query_impl[f150d155ff7d55dc]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7f9925bd2867 - <rustc_interface[6aac31471fbf89a2]::passes::create_and_enter_global_ctxt<core[6fc5908a1b7800da]::option::Option<rustc_interface[6aac31471fbf89a2]::queries::Linker>, rustc_driver_impl[286b0c75f16868d8]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[6fc5908a1b7800da]::ops::function::FnOnce<(&rustc_session[a59760342050988b]::session::Session, rustc_middle[c35976215db85e11]::ty::context::CurrentGcx, alloc[9583f8edfca66464]::sync::Arc<rustc_data_structures[ad856ab7d49c9531]::jobserver::Proxy>, &std[3caa9718c767cdb0]::sync::once_lock::OnceLock<rustc_middle[c35976215db85e11]::ty::context::GlobalCtxt>, &rustc_data_structures[ad856ab7d49c9531]::sync::worker_local::WorkerLocal<rustc_middle[c35976215db85e11]::arena::Arena>, &rustc_data_structures[ad856ab7d49c9531]::sync::worker_local::WorkerLocal<rustc_hir[6d7b1c09e497802f]::Arena>, rustc_driver_impl[286b0c75f16868d8]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  24:     0x7f99259ffbf7 - rustc_interface[6aac31471fbf89a2]::interface::run_compiler::<(), rustc_driver_impl[286b0c75f16868d8]::run_compiler::{closure#0}>::{closure#1}
  25:     0x7f9925a2283e - std[3caa9718c767cdb0]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[6aac31471fbf89a2]::util::run_in_thread_with_globals<rustc_interface[6aac31471fbf89a2]::util::run_in_thread_pool_with_globals<rustc_interface[6aac31471fbf89a2]::interface::run_compiler<(), rustc_driver_impl[286b0c75f16868d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x7f9925a22d60 - <std[3caa9718c767cdb0]::thread::lifecycle::spawn_unchecked<rustc_interface[6aac31471fbf89a2]::util::run_in_thread_with_globals<rustc_interface[6aac31471fbf89a2]::util::run_in_thread_pool_with_globals<rustc_interface[6aac31471fbf89a2]::interface::run_compiler<(), rustc_driver_impl[286b0c75f16868d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[6fc5908a1b7800da]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7f9925a23bec - <std[3caa9718c767cdb0]::sys::thread::unix::Thread>::new::thread_start
  28:     0x7f991f29698b - <unknown>
  29:     0x7f991f31a9cc - <unknown>
  30:                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.95.0-nightly (5fdff787e 2026-02-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

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

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

@rustbot label +WG-trait-system-refactor

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions