Skip to content

ICE: infer: index out of bounds: the len is 0 but the index is 0 #133613

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

struct Wrapper<'a, 'b>(T)

trait IntFactory {
    fn stream(&self) -> impl IntFactory<stream(..): IntFactory<stream(..): Send> + Send>;
    
}

fn main() {}

original:

struct Wrapper<'a, 'b>(T)

trait IntFactory {
    fn stream(&self) -> impl IntFactory<stream(..): IntFactory<stream(..): Send> + Send>;
    //~^ ERROR cycle detected when resolving lifetimes for `IntFactory::stream`
}

fn main() {}

Version information

rustc 1.85.0-nightly (d6f88291f 2024-11-29)
binary: rustc
commit-hash: d6f88291f3ce96375683acc62d54710add042f98
commit-date: 2024-11-29
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Possibly related line of code:

struct ToFreshVars<'tcx> {
args: Vec<ty::GenericArg<'tcx>>,
}
impl<'tcx> BoundVarReplacerDelegate<'tcx> for ToFreshVars<'tcx> {
fn replace_region(&mut self, br: ty::BoundRegion) -> ty::Region<'tcx> {
self.args[br.var.index()].expect_region()
}
fn replace_ty(&mut self, bt: ty::BoundTy) -> Ty<'tcx> {
self.args[bt.var.index()].expect_ty()
}
fn replace_const(&mut self, bv: ty::BoundVar) -> ty::Const<'tcx> {
self.args[bv.index()].expect_const()

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

Program output

error: expected `;`, found keyword `trait`
 --> /tmp/icemaker_global_tempdir.FqLUzmaudTzI/rustc_testrunner_tmpdir_reporting.xdJGS2xYMk6C/mvce.rs:1:26
  |
1 | struct Wrapper<'a, 'b>(T)
  |                          ^ help: add `;` here
2 |
3 | trait IntFactory {
  | ----- unexpected token

error[E0412]: cannot find type `T` in this scope
 --> /tmp/icemaker_global_tempdir.FqLUzmaudTzI/rustc_testrunner_tmpdir_reporting.xdJGS2xYMk6C/mvce.rs:1:24
  |
1 | struct Wrapper<'a, 'b>(T)
  |                        ^ not found in this scope
  |
help: you might be missing a type parameter
  |
1 | struct Wrapper<'a, 'b, T>(T)
  |                      +++

error[E0658]: return type notation is experimental
 --> /tmp/icemaker_global_tempdir.FqLUzmaudTzI/rustc_testrunner_tmpdir_reporting.xdJGS2xYMk6C/mvce.rs:4:47
  |
4 |     fn stream(&self) -> impl IntFactory<stream(..): IntFactory<stream(..): Send> + Send>;
  |                                               ^^^^
  |
  = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
  = help: add `#![feature(return_type_notation)]` to the crate attributes to enable
  = note: this compiler was built on 2024-11-29; consider upgrading it if it is out of date

error[E0658]: return type notation is experimental
 --> /tmp/icemaker_global_tempdir.FqLUzmaudTzI/rustc_testrunner_tmpdir_reporting.xdJGS2xYMk6C/mvce.rs:4:70
  |
4 |     fn stream(&self) -> impl IntFactory<stream(..): IntFactory<stream(..): Send> + Send>;
  |                                                                      ^^^^
  |
  = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
  = help: add `#![feature(return_type_notation)]` to the crate attributes to enable
  = note: this compiler was built on 2024-11-29; consider upgrading it if it is out of date

thread 'rustc' panicked at compiler/rustc_infer/src/infer/mod.rs:1219:26:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7fe9dbf5972a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hec1837868ef45960
   1:     0x7fe9dc613d22 - core::fmt::write::h8542321c14f36bce
   2:     0x7fe9dd9c9291 - std::io::Write::write_fmt::hf2a72a9478b52b86
   3:     0x7fe9dbf59582 - std::sys::backtrace::BacktraceLock::print::h54b78d015c817d7f
   4:     0x7fe9dbf5ba8a - std::panicking::default_hook::{{closure}}::h59fe07b020797497
   5:     0x7fe9dbf5b8d3 - std::panicking::default_hook::h95e9258765c75220
   6:     0x7fe9db0d8428 - std[8cd9e1f924e20ad9]::panicking::update_hook::<alloc[e7baf234c2c812f]::boxed::Box<rustc_driver_impl[14afabfc160a9240]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7fe9dbf5c248 - std::panicking::rust_panic_with_hook::hc2d98b5446c61d2e
   8:     0x7fe9dbf5bf3a - std::panicking::begin_panic_handler::{{closure}}::h835f83c27c39eff3
   9:     0x7fe9dbf59bd9 - std::sys::backtrace::__rust_end_short_backtrace::h1c30ff1ce1e39439
  10:     0x7fe9dbf5bbfd - rust_begin_unwind
  11:     0x7fe9d94976d0 - core::panicking::panic_fmt::h0563cf7c13bf6d1f
  12:     0x7fe9da8282e6 - core::panicking::panic_bounds_check::h37a714e361d2a1ae
  13:     0x7fe9dcee16f8 - <&rustc_middle[27682da1f3d8f4de]::ty::list::RawList<(), rustc_middle[27682da1f3d8f4de]::ty::generic_args::GenericArg> as rustc_type_ir[b61a683bada45ed3]::fold::TypeFoldable<rustc_middle[27682da1f3d8f4de]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[27682da1f3d8f4de]::ty::fold::BoundVarReplacer<<rustc_infer[279a1b95418dab6f]::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars>>
  14:     0x7fe9dcee2620 - <rustc_middle[27682da1f3d8f4de]::ty::fold::BoundVarReplacer<<rustc_infer[279a1b95418dab6f]::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars> as rustc_type_ir[b61a683bada45ed3]::fold::TypeFolder<rustc_middle[27682da1f3d8f4de]::ty::context::TyCtxt>>::fold_ty
  15:     0x7fe9dcee1544 - <&rustc_middle[27682da1f3d8f4de]::ty::list::RawList<(), rustc_middle[27682da1f3d8f4de]::ty::generic_args::GenericArg> as rustc_type_ir[b61a683bada45ed3]::fold::TypeFoldable<rustc_middle[27682da1f3d8f4de]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[27682da1f3d8f4de]::ty::fold::BoundVarReplacer<<rustc_infer[279a1b95418dab6f]::infer::InferCtxt>::instantiate_binder_with_fresh_vars::ToFreshVars>>
  16:     0x7fe9dcee0f75 - <rustc_infer[279a1b95418dab6f]::infer::InferCtxt>::instantiate_binder_with_fresh_vars::<rustc_type_ir[b61a683bada45ed3]::predicate::TraitRef<rustc_middle[27682da1f3d8f4de]::ty::context::TyCtxt>>
  17:     0x7fe9d9649431 - <rustc_trait_selection[dbc08e0067937613]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  18:     0x7fe9d96908e4 - <rustc_trait_selection[dbc08e0067937613]::traits::select::SelectionContext>::poly_select::{closure#0}
  19:     0x7fe9dcdee4ad - rustc_trait_selection[dbc08e0067937613]::traits::project::opt_normalize_projection_term
  20:     0x7fe9dcde9715 - <rustc_trait_selection[dbc08e0067937613]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[b61a683bada45ed3]::fold::TypeFolder<rustc_middle[27682da1f3d8f4de]::ty::context::TyCtxt>>::fold_ty
  21:     0x7fe9dcd86e15 - <&rustc_middle[27682da1f3d8f4de]::ty::list::RawList<(), rustc_middle[27682da1f3d8f4de]::ty::generic_args::GenericArg> as rustc_type_ir[b61a683bada45ed3]::fold::TypeFoldable<rustc_middle[27682da1f3d8f4de]::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection[dbc08e0067937613]::traits::normalize::AssocTypeNormalizer>
  22:     0x7fe9dcd86c5a - <rustc_trait_selection[dbc08e0067937613]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[b61a683bada45ed3]::fold::FallibleTypeFolder<rustc_middle[27682da1f3d8f4de]::ty::context::TyCtxt>>::try_fold_predicate
  23:     0x7fe9dd64dd70 - rustc_trait_selection[dbc08e0067937613]::traits::normalize::normalize_with_depth_to::<rustc_middle[27682da1f3d8f4de]::ty::predicate::Clause>::{closure#0}
  24:     0x7fe9dd64d953 - <rustc_trait_selection[dbc08e0067937613]::traits::engine::ObligationCtxt<rustc_trait_selection[dbc08e0067937613]::traits::FulfillmentError>>::normalize::<rustc_middle[27682da1f3d8f4de]::ty::predicate::Clause>
  25:     0x7fe9dd64d76a - <rustc_hir_analysis[36ad47a662f37d3b]::check::wfcheck::WfCheckingCtxt>::normalize::<rustc_middle[27682da1f3d8f4de]::ty::predicate::Clause>
  26:     0x7fe9dcd8da1f - rustc_hir_analysis[36ad47a662f37d3b]::check::wfcheck::check_associated_item
  27:     0x7fe9dd0b4784 - rustc_hir_analysis[36ad47a662f37d3b]::check::wfcheck::check_well_formed
  28:     0x7fe9dd0b3e75 - rustc_query_impl[4f8f76f3d31f708e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4f8f76f3d31f708e]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[27682da1f3d8f4de]::query::erase::Erased<[u8; 1usize]>>
  29:     0x7fe9dd0b3642 - rustc_query_system[8e784080364d5611]::query::plumbing::try_execute_query::<rustc_query_impl[4f8f76f3d31f708e]::DynamicConfig<rustc_data_structures[d2e27b1fdf5c45a]::vec_cache::VecCache<rustc_span[c479824c5b44d1f2]::def_id::LocalDefId, rustc_middle[27682da1f3d8f4de]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[8e784080364d5611]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[4f8f76f3d31f708e]::plumbing::QueryCtxt, false>
  30:     0x7fe9dd0b3346 - rustc_query_impl[4f8f76f3d31f708e]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7fe9dd0b062b - rustc_middle[27682da1f3d8f4de]::query::plumbing::query_ensure_error_guaranteed::<rustc_data_structures[d2e27b1fdf5c45a]::vec_cache::VecCache<rustc_span[c479824c5b44d1f2]::def_id::LocalDefId, rustc_middle[27682da1f3d8f4de]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[8e784080364d5611]::dep_graph::graph::DepNodeIndex>, ()>
  32:     0x7fe9dd0b0ab8 - rustc_hir_analysis[36ad47a662f37d3b]::check::wfcheck::check_mod_type_wf
  33:     0x7fe9dd0b064b - rustc_query_impl[4f8f76f3d31f708e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4f8f76f3d31f708e]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[27682da1f3d8f4de]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7fe9dd15be48 - rustc_query_system[8e784080364d5611]::query::plumbing::try_execute_query::<rustc_query_impl[4f8f76f3d31f708e]::DynamicConfig<rustc_query_system[8e784080364d5611]::query::caches::DefaultCache<rustc_span[c479824c5b44d1f2]::def_id::LocalModDefId, rustc_middle[27682da1f3d8f4de]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[4f8f76f3d31f708e]::plumbing::QueryCtxt, false>
  35:     0x7fe9dd15bbf0 - rustc_query_impl[4f8f76f3d31f708e]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7fe9dc84e4dc - rustc_hir_analysis[36ad47a662f37d3b]::check_crate
  37:     0x7fe9dcf5c9fc - rustc_interface[c5a3bcc8dca6839d]::passes::run_required_analyses
  38:     0x7fe9dcf5759e - rustc_interface[c5a3bcc8dca6839d]::passes::analysis
  39:     0x7fe9dcf5756f - rustc_query_impl[4f8f76f3d31f708e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4f8f76f3d31f708e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[27682da1f3d8f4de]::query::erase::Erased<[u8; 1usize]>>
  40:     0x7fe9dd56623a - rustc_query_system[8e784080364d5611]::query::plumbing::try_execute_query::<rustc_query_impl[4f8f76f3d31f708e]::DynamicConfig<rustc_query_system[8e784080364d5611]::query::caches::SingleCache<rustc_middle[27682da1f3d8f4de]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[4f8f76f3d31f708e]::plumbing::QueryCtxt, false>
  41:     0x7fe9dd565f0e - rustc_query_impl[4f8f76f3d31f708e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7fe9dd5fc407 - rustc_interface[c5a3bcc8dca6839d]::interface::run_compiler::<core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>, rustc_driver_impl[14afabfc160a9240]::run_compiler::{closure#0}>::{closure#1}
  43:     0x7fe9dd532fe1 - std[8cd9e1f924e20ad9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c5a3bcc8dca6839d]::util::run_in_thread_with_globals<rustc_interface[c5a3bcc8dca6839d]::util::run_in_thread_pool_with_globals<rustc_interface[c5a3bcc8dca6839d]::interface::run_compiler<core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>, rustc_driver_impl[14afabfc160a9240]::run_compiler::{closure#0}>::{closure#1}, core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>>::{closure#0}, core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>>
  44:     0x7fe9dd532c88 - <<std[8cd9e1f924e20ad9]::thread::Builder>::spawn_unchecked_<rustc_interface[c5a3bcc8dca6839d]::util::run_in_thread_with_globals<rustc_interface[c5a3bcc8dca6839d]::util::run_in_thread_pool_with_globals<rustc_interface[c5a3bcc8dca6839d]::interface::run_compiler<core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>, rustc_driver_impl[14afabfc160a9240]::run_compiler::{closure#0}>::{closure#1}, core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>>::{closure#0}, core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5de9dc4edf684167]::result::Result<(), rustc_span[c479824c5b44d1f2]::ErrorGuaranteed>>::{closure#1} as core[5de9dc4edf684167]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fe9dd5323bb - std::sys::pal::unix::thread::Thread::new::thread_start::h54530dbf71bba30b
  46:     0x7fe9dedc439d - <unknown>
  47:     0x7fe9dee4949c - <unknown>
  48:                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.85.0-nightly (d6f88291f 2024-11-29) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `IntFactory::stream` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
end of query stack
error: aborting due to 4 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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