Repository: rust
Issue: Compiler Unexpected Panic: index out of bounds
Labels: I-ICE,T-compiler,A-incr-comp,C-bug

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.

http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/

-->

### Code
I'm not sure how to produce an minimal example here... but I tried to compile `ark-bcs` crate here: https://github.com/arkworks-rs/bcs/tree/7c8539b3bd84768abc920897ac6aacf178403f03


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.59.0-nightly (f8abed9ed 2021-12-26)
binary: rustc
commit-hash: f8abed9ed48bace6be0087bcd44ed534e239b8d8
commit-date: 2021-12-26
host: x86_64-pc-windows-msvc
release: 1.59.0-nightly
LLVM version: 13.0.0

```

### Error output

```
thread 'rustc' panicked at 'index out of bounds: the len is 379 but the index is 389', compiler\rustc_query_impl\src\on_disk_cache.rs:712:18                                                                  
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic
note: 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.59.0-nightly (f8abed9ed 2021-12-26) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [type_of] computing type of `bcs::simulation_transcript::SimulationTranscript::prover_messages_info`
#1 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
end of query stack
error: could not compile `ark-bcs`

```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
thread 'rustc' panicked at 'index out of bounds: the len is 379 but the index is 389', compiler\rustc_query_impl\src\on_disk_cache.rs:712:18
stack backtrace:
   0:     0x7ffe571d677f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha14ac31702ace1f3
   1:     0x7ffe5720444a - core::fmt::write::h0b23fe237025484e
   2:     0x7ffe571c7df8 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h3bfbf14ba3d5317f
   3:     0x7ffe571d9f26 - std::panicking::take_hook::hffa15ec901b97064
   4:     0x7ffe571d9a09 - std::panicking::take_hook::hffa15ec901b97064
   5:     0x7ffe30cf1cd9 - <[i8] as rand[bcd226d3eaf62888]::AsByteSliceMut>::to_le
   6:     0x7ffe571da789 - std::panicking::rust_panic_with_hook::h145f4955d18516ac
   7:     0x7ffe571da50b - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::hc5a1161d800cf4b9
   8:     0x7ffe571d70a7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha14ac31702ace1f3
   9:     0x7ffe571da239 - rust_begin_unwind
  10:     0x7ffe57236cb0 - core::panicking::panic_fmt::h8e2ecdf5d83ec6e4
  11:     0x7ffe57236c77 - core::panicking::panic_bounds_check::h737a948987edb2cc
  12:     0x7ffe345f7f0b - <rustc_span[2116069557bae9a5]::span_encoding::Span as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDecoder>>::de
code
  13:     0x7ffe345accc6 - <&[(rustc_middle[7b7365041b54fb0d]::ty::Predicate, rustc_span[2116069557bae9a5]::span_encoding::Span)] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[
a59bb0577500cd34]::on_disk_cache::CacheDecoder>>::decode
  14:     0x7ffe3448dd60 - rustc_query_impl[a59bb0577500cd34]::query_callbacks::diagnostic_hir_wf_check
  15:     0x7ffe3445a083 - RNvXsd_NtCsedwKXTSOeye_16rustc_query_impl13on_disk_cacheRINtNtNtNtCseSmLWCZGRrf_3std11collections4hash3set7HashSetNtNtCs2Q7cGApXuuL_10rustc_span6def_id10LocalDefIdINtNtCsf4aqhrItn
GP_4core4hash18BuildHasherDefaultNtCskeHs41vGeAj_10rustc_hash8FxHasherEEINtN
  16:     0x7ffe344087f8 - <rustc_query_impl[a59bb0577500cd34]::Queries as rustc_middle[7b7365041b54fb0d]::ty::query::QueryEngine>::try_mark_green
  17:     0x7ffe3459def9 - <&[(rustc_middle[7b7365041b54fb0d]::ty::Predicate, rustc_span[2116069557bae9a5]::span_encoding::Span)] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[
a59bb0577500cd34]::on_disk_cache::CacheDecoder>>::decode
  18:     0x7ffe344a30f4 - <rustc_query_impl[a59bb0577500cd34]::on_disk_cache::OnDiskCache>::load_side_effects
  19:     0x7ffe3459dfe8 - <&[(rustc_middle[7b7365041b54fb0d]::ty::Predicate, rustc_span[2116069557bae9a5]::span_encoding::Span)] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[
a59bb0577500cd34]::on_disk_cache::CacheDecoder>>::decode
  20:     0x7ffe3444eeea - RNvXsd_NtCsedwKXTSOeye_16rustc_query_impl13on_disk_cacheRINtNtNtNtCseSmLWCZGRrf_3std11collections4hash3set7HashSetNtNtCs2Q7cGApXuuL_10rustc_span6def_id10LocalDefIdINtNtCsf4aqhrItn
GP_4core4hash18BuildHasherDefaultNtCskeHs41vGeAj_10rustc_hash8FxHasherEEINtN
  21:     0x7ffe344508eb - RNvXsd_NtCsedwKXTSOeye_16rustc_query_impl13on_disk_cacheRINtNtNtNtCseSmLWCZGRrf_3std11collections4hash3set7HashSetNtNtCs2Q7cGApXuuL_10rustc_span6def_id10LocalDefIdINtNtCsf4aqhrItn
GP_4core4hash18BuildHasherDefaultNtCskeHs41vGeAj_10rustc_hash8FxHasherEEINtN
  22:     0x7ffe3459e0f3 - <&[(rustc_middle[7b7365041b54fb0d]::ty::Predicate, rustc_span[2116069557bae9a5]::span_encoding::Span)] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[
a59bb0577500cd34]::on_disk_cache::CacheDecoder>>::decode
  23:     0x7ffe34408f04 - <rustc_query_impl[a59bb0577500cd34]::Queries as rustc_middle[7b7365041b54fb0d]::ty::query::QueryEngine>::try_mark_green
  24:     0x7ffe3459def9 - <&[(rustc_middle[7b7365041b54fb0d]::ty::Predicate, rustc_span[2116069557bae9a5]::span_encoding::Span)] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[
a59bb0577500cd34]::on_disk_cache::CacheDecoder>>::decode
  25:     0x7ffe344a09c9 - <rustc_query_impl[a59bb0577500cd34]::on_disk_cache::OnDiskCache>::load_side_effects
  26:     0x7ffe342fd32b - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  27:     0x7ffe343c9482 - <rustc_query_impl[a59bb0577500cd34]::Queries>::as_dyn
  28:     0x7ffe34289093 - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  29:     0x7ffe343761d8 - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  30:     0x7ffe338b8ab6 - <rustc_typeck[941f9db1b1bb2212]::outlives::implicit_infer::InferVisitor as rustc_hir[833e587e30f5cbff]::itemlikevisit::ItemLikeVisitor>::visit_item
  31:     0x7ffe3381fe3e - <<rustc_typeck[941f9db1b1bb2212]::coherence::inherent_impls_overlap::InherentOverlapChecker as rustc_hir[833e587e30f5cbff]::itemlikevisit::ItemLikeVisitor>::visit_item::RegionId a
s core[af7f507fbd0dfa75]::fmt::Debug>::fmt
  32:     0x7ffe33860b83 - <rustc_typeck[941f9db1b1bb2212]::hir_wf_check::EraseAllBoundRegions as rustc_middle[7b7365041b54fb0d]::ty::fold::TypeFolder>::fold_region
  33:     0x7ffe34410de3 - <rustc_query_impl[a59bb0577500cd34]::Queries as rustc_middle[7b7365041b54fb0d]::ty::query::QueryEngine>::try_mark_green
  34:     0x7ffe345467b5 - <&[rustc_ast[f9ec3740b9f34bac]::ast::InlineAsmTemplatePiece] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDec
oder>>::decode
  35:     0x7ffe343d9f7c - <rustc_query_impl[a59bb0577500cd34]::Queries>::as_dyn
  36:     0x7ffe34216047 - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  37:     0x7ffe3439831c - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  38:     0x7ffe3446f697 - rustc_query_impl[a59bb0577500cd34]::query_callbacks::inferred_outlives_crate
  39:     0x7ffe351b6063 - <rustc_middle[7b7365041b54fb0d]::ty::context::TyCtxt as rustc_query_system[e50ba6d3456cebe9]::dep_graph::DepContext>::try_force_from_dep_node
  40:     0x7ffe345742fb - <&[rustc_ast[f9ec3740b9f34bac]::ast::InlineAsmTemplatePiece] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDec
oder>>::decode
  41:     0x7ffe345742d7 - <&[rustc_ast[f9ec3740b9f34bac]::ast::InlineAsmTemplatePiece] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDec
oder>>::decode
  42:     0x7ffe345742d7 - <&[rustc_ast[f9ec3740b9f34bac]::ast::InlineAsmTemplatePiece] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDec
oder>>::decode
  43:     0x7ffe345742d7 - <&[rustc_ast[f9ec3740b9f34bac]::ast::InlineAsmTemplatePiece] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDec
oder>>::decode
  44:     0x7ffe34573f6a - <&[rustc_ast[f9ec3740b9f34bac]::ast::InlineAsmTemplatePiece] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDec
oder>>::decode
  45:     0x7ffe3432b88c - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  46:     0x7ffe34356860 - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  47:     0x7ffe338212d2 - <<rustc_typeck[941f9db1b1bb2212]::coherence::inherent_impls_overlap::InherentOverlapChecker as rustc_hir[833e587e30f5cbff]::itemlikevisit::ItemLikeVisitor>::visit_item::RegionId a
s core[af7f507fbd0dfa75]::fmt::Debug>::fmt
  48:     0x7ffe3375a4b8 - <rustc_typeck[941f9db1b1bb2212]::check::dropck::SimpleEqRelation as rustc_middle[7b7365041b54fb0d]::ty::relate::TypeRelation>::regions
  49:     0x7ffe3372f375 - rustc_typeck[941f9db1b1bb2212]::check_crate
  50:     0x7ffe30e682bf - rustc_interface[9eb461368c5c4705]::passes::analysis
  51:     0x7ffe34410afb - <rustc_query_impl[a59bb0577500cd34]::Queries as rustc_middle[7b7365041b54fb0d]::ty::query::QueryEngine>::try_mark_green
  52:     0x7ffe34543dbe - <&[rustc_ast[f9ec3740b9f34bac]::ast::InlineAsmTemplatePiece] as rustc_serialize[ba830b73d8fe109f]::serialize::Decodable<rustc_query_impl[a59bb0577500cd34]::on_disk_cache::CacheDec
oder>>::decode
  53:     0x7ffe343d75d1 - <rustc_query_impl[a59bb0577500cd34]::Queries>::as_dyn
  54:     0x7ffe342d6b49 - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  55:     0x7ffe34376322 - <rustc_mir_dataflow[a4416aab894c7aab]::impls::storage_liveness::MaybeRequiresStorage as rustc_mir_dataflow[a4416aab894c7aab]::framework::AnalysisDomain>::initialize_start_block   
  56:     0x7ffe30d7c180 - <rustc_driver[55170faa71b16ce8]::args::Error as core[af7f507fbd0dfa75]::fmt::Debug>::fmt
  57:     0x7ffe30d71aa6 - <rustc_middle[7b7365041b54fb0d]::ty::SymbolName as core[af7f507fbd0dfa75]::fmt::Display>::fmt
  58:     0x7ffe30d0e7e5 - rustc_driver[55170faa71b16ce8]::pretty::print_after_hir_lowering
  59:     0x7ffe30d6fe73 - <rustc_middle[7b7365041b54fb0d]::ty::SymbolName as core[af7f507fbd0dfa75]::fmt::Display>::fmt
  60:     0x7ffe30d1b7d3 - <tracing_subscriber[ccd8b77676e2f7da]::util::TryInitError as core[af7f507fbd0dfa75]::fmt::Display>::fmt
  61:     0x7ffe30d8d488 - <rustc_driver[55170faa71b16ce8]::args::Error as core[af7f507fbd0dfa75]::fmt::Debug>::fmt
  62:     0x7ffe571e92dc - std::sys::windows::thread::Thread::new::hb9be5e253c09c837
  63:     0x7ffec48d7034 - BaseThreadInitThunk
  64:     0x7ffec5c22651 - RtlUserThreadStart

```

</p>
</details>