Repository: rust
Issue: ICE: index out of bounds: the len is 1 but the index is 1', compiler/rustc_metadata/src/rmeta/decoder.rs:803:53
Labels: I-ICE,T-compiler,C-bug,requires-debug-assertions,requires-custom-config

<!--
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
this happened while building `rustc-std-workspace-core` stage1 with rustc + debug assertions
```Rust
#![feature(no_core)]
#![no_core]

pub use core::*;
```


### 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`:
```
1dda298ad39a64e019a3511139c5b13ac0a18e54
```

### Error output

```
<output>
```

<!--
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>

```
Building rustbuild
    Finished dev [unoptimized] target(s) in 0.11s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.20s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized + debuginfo] target(s) in 0.39s
Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling rustc-std-workspace-core v1.99.0 (/home/matthias/vcs/github/rust_debug_assertions/library/rustc-std-workspace-core)
thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', compiler/rustc_metadata/src/rmeta/decoder.rs:803:53
stack backtrace:
   0: rust_begin_unwind
             at ./library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at ./library/core/src/panicking.rs:65:14
   2: core::panicking::panic_bounds_check
             at ./library/core/src/panicking.rs:150:5
   3: <usize as core::slice::index::SliceIndex<[rustc_span::def_id::CrateNum]>>::index
             at ./library/core/src/slice/index.rs:259:10
   4: <[rustc_span::def_id::CrateNum] as core::ops::index::Index<usize>>::index
             at ./library/core/src/slice/index.rs:18:9
   5: <alloc::vec::Vec<rustc_span::def_id::CrateNum> as core::ops::index::Index<usize>>::index
             at ./library/alloc/src/vec/mod.rs:2736:9
   6: <rustc_index::vec::IndexVec<rustc_span::def_id::CrateNum, rustc_span::def_id::CrateNum> as core::ops::index::Index<rustc_span::def_id::CrateNum>>::index
             at ./compiler/rustc_index/src/vec.rs:337:10
   7: <rustc_metadata::creader::CrateMetadataRef>::map_encoded_cnum_to_current
             at ./compiler/rustc_metadata/src/rmeta/decoder.rs:803:53
   8: <rustc_metadata::rmeta::decoder::DecodeContext>::map_encoded_cnum_to_current
             at ./compiler/rustc_metadata/src/rmeta/decoder.rs:336:9
   9: <rustc_span::def_id::CrateNum as rustc_serialize::serialize::Decodable<rustc_metadata::rmeta::decoder::DecodeContext>>::decode
             at ./compiler/rustc_metadata/src/rmeta/decoder.rs:436:9
  10: <rustc_span::def_id::DefId as rustc_serialize::serialize::Decodable<rustc_metadata::rmeta::decoder::DecodeContext>>::decode
             at ./compiler/rustc_span/src/def_id.rs:341:24
  11: <rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId> as rustc_serialize::serialize::Decodable<rustc_metadata::rmeta::decoder::DecodeContext>>::decode
             at ./compiler/rustc_middle/src/ty/fast_reject.rs:19:64
  12: <rustc_metadata::rmeta::IncoherentImpls as rustc_serialize::serialize::Decodable<rustc_metadata::rmeta::decoder::DecodeContext>>::decode
             at ./compiler/rustc_metadata/src/rmeta/mod.rs:310:29
  13: <rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls> as core::iter::traits::iterator::Iterator>::next::{closure#0}
             at ./compiler/rustc_metadata/src/rmeta/decoder.rs:280:42
  14: <core::option::Option<usize>>::map::<rustc_metadata::rmeta::IncoherentImpls, <rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls> as core::iter::traits::iterator::Iterator>::next::{closure#0}>
             at ./library/core/src/option.rs:925:29
  15: <rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls> as core::iter::traits::iterator::Iterator>::next
             at ./compiler/rustc_metadata/src/rmeta/decoder.rs:280:9
  16: <rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::adapters::map::map_fold<rustc_metadata::rmeta::IncoherentImpls, (rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>), (), <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}, core::iter::traits::iterator::Iterator::for_each::call<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>), <hashbrown::map::HashMap<rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>> as core::iter::traits::collect::Extend<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>)>>::extend<core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}>>::{closure#0}>::{closure#0}>::{closure#0}>
             at ./library/core/src/iter/traits/iterator.rs:2413:29
  17: <core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>), <hashbrown::map::HashMap<rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>> as core::iter::traits::collect::Extend<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>)>>::extend<core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}>>::{closure#0}>::{closure#0}>
             at ./library/core/src/iter/adapters/map.rs:124:9
  18: <core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}> as core::iter::traits::iterator::Iterator>::for_each::<<hashbrown::map::HashMap<rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>> as core::iter::traits::collect::Extend<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>)>>::extend<core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}>>::{closure#0}>
             at ./library/core/src/iter/traits/iterator.rs:831:9
  19: <hashbrown::map::HashMap<rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>> as core::iter::traits::collect::Extend<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>)>>::extend::<core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}>>
             at /home/matthias/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.12.3/src/map.rs:6407:9
  20: <std::collections::hash::map::HashMap<rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>> as core::iter::traits::collect::Extend<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>)>>::extend::<core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}>>
             at ./library/std/src/collections/hash/map.rs:3037:9
  21: <std::collections::hash::map::HashMap<rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>> as core::iter::traits::collect::FromIterator<(rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>)>>::from_iter::<core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}>>
             at ./library/std/src/collections/hash/map.rs:3022:9
  22: <core::iter::adapters::map::Map<rustc_metadata::rmeta::decoder::DecodeIterator<rustc_metadata::rmeta::IncoherentImpls>, <rustc_metadata::rmeta::decoder::CrateMetadata>::new::{closure#1}> as core::iter::traits::iterator::Iterator>::collect::<std::collections::hash::map::HashMap<rustc_middle::ty::fast_reject::SimplifiedTypeGen<rustc_span::def_id::DefId>, rustc_metadata::rmeta::LazyArray<rustc_span::def_id::DefIndex>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>
             at ./library/core/src/iter/traits/iterator.rs:1836:9
  23: <rustc_metadata::rmeta::decoder::CrateMetadata>::new
             at ./compiler/rustc_metadata/src/rmeta/decoder.rs:1680:34
  24: <rustc_metadata::creader::CrateLoader>::register_crate
             at ./compiler/rustc_metadata/src/creader.rs:443:30
  25: <rustc_metadata::creader::CrateLoader>::maybe_resolve_crate
             at ./compiler/rustc_metadata/src/creader.rs:595:17
  26: <rustc_metadata::creader::CrateLoader>::maybe_process_path_extern
             at ./compiler/rustc_metadata/src/creader.rs:1050:9
  27: <rustc_resolve::Resolver>::extern_prelude_get::{closure#0}
             at ./compiler/rustc_resolve/src/lib.rs:1872:21
  28: <core::option::Option<rustc_resolve::ExternPreludeEntry>>::and_then::<&rustc_resolve::NameBinding, <rustc_resolve::Resolver>::extern_prelude_get::{closure#0}>
             at ./library/core/src/option.rs:1264:24
  29: <rustc_resolve::Resolver>::extern_prelude_get
             at ./compiler/rustc_resolve/src/lib.rs:1860:9
  30: <rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope::{closure#0}
             at ./compiler/rustc_resolve/src/ident.rs:524:31
  31: <rustc_resolve::Resolver>::visit_scopes::<core::result::Result<&rustc_resolve::NameBinding, rustc_resolve::Determinacy>, <rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope::{closure#0}>
             at ./compiler/rustc_resolve/src/ident.rs:140:50
  32: <rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope
             at ./compiler/rustc_resolve/src/ident.rs:382:28
  33: <rustc_resolve::Resolver>::resolve_path_with_ribs::{closure#3}
             at ./compiler/rustc_resolve/src/ident.rs:1410:21
  34: <rustc_resolve::Resolver>::resolve_path_with_ribs
             at ./compiler/rustc_resolve/src/ident.rs:1421:33
  35: <rustc_resolve::Resolver>::maybe_resolve_path
             at ./compiler/rustc_resolve/src/ident.rs:1264:9
  36: <rustc_resolve::imports::ImportResolver>::resolve_import
             at ./compiler/rustc_resolve/src/imports.rs:573:17
  37: <rustc_resolve::imports::ImportResolver>::resolve_imports
             at ./compiler/rustc_resolve/src/imports.rs:430:23
  38: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::resolve_imports
             at ./compiler/rustc_resolve/src/macros.rs:235:9
  39: <rustc_expand::expand::MacroExpander>::resolve_imports
             at ./compiler/rustc_expand/src/expand.rs:549:13
  40: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
             at ./compiler/rustc_expand/src/expand.rs:415:9
  41: <rustc_expand::expand::MacroExpander>::expand_crate
             at ./compiler/rustc_expand/src/expand.rs:398:21
  42: rustc_interface::passes::configure_and_expand::{closure#1}::{closure#1}
             at ./compiler/rustc_interface/src/passes.rs:335:50
  43: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<rustc_ast::ast::Crate, rustc_interface::passes::configure_and_expand::{closure#1}::{closure#1}>
             at ./compiler/rustc_data_structures/src/profiling.rs:727:9
  44: <rustc_session::session::Session>::time::<rustc_ast::ast::Crate, rustc_interface::passes::configure_and_expand::{closure#1}::{closure#1}>
             at ./compiler/rustc_session/src/utils.rs:10:9
  45: rustc_interface::passes::configure_and_expand::{closure#1}
             at ./compiler/rustc_interface/src/passes.rs:335:21
  46: <rustc_data_structures::profiling::VerboseTimingGuard>::run::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>, rustc_interface::passes::configure_and_expand::{closure#1}>
             at ./compiler/rustc_data_structures/src/profiling.rs:727:9
  47: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>, rustc_interface::passes::configure_and_expand::{closure#1}>
             at ./compiler/rustc_session/src/utils.rs:10:9
  48: rustc_interface::passes::configure_and_expand
             at ./compiler/rustc_interface/src/passes.rs:287:13
  49: <rustc_interface::queries::Queries>::expansion::{closure#0}::{closure#0}
             at ./compiler/rustc_interface/src/queries.rs:178:17
  50: <rustc_interface::passes::boxed_resolver::BoxedResolver>::access::<<rustc_interface::queries::Queries>::expansion::{closure#0}::{closure#0}, core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorGuaranteed>>
             at ./compiler/rustc_interface/src/passes.rs:134:13
  51: <rustc_interface::queries::Queries>::expansion::{closure#0}
             at ./compiler/rustc_interface/src/queries.rs:177:25
  52: <core::option::Option<core::result::Result<(alloc::rc::Rc<rustc_ast::ast::Crate>, alloc::rc::Rc<core::cell::RefCell<rustc_interface::passes::boxed_resolver::BoxedResolver>>, alloc::rc::Rc<rustc_lint::context::LintStore>), rustc_errors::ErrorGuaranteed>>>::get_or_insert_with::<<rustc_interface::queries::Queries>::expansion::{closure#0}>
             at ./library/core/src/option.rs:1546:49
  53: <rustc_interface::queries::Query<(alloc::rc::Rc<rustc_ast::ast::Crate>, alloc::rc::Rc<core::cell::RefCell<rustc_interface::passes::boxed_resolver::BoxedResolver>>, alloc::rc::Rc<rustc_lint::context::LintStore>)>>::compute::<<rustc_interface::queries::Queries>::expansion::{closure#0}>
             at ./compiler/rustc_interface/src/queries.rs:36:9
  54: <rustc_interface::queries::Queries>::expansion
             at ./compiler/rustc_interface/src/queries.rs:166:9
  55: rustc_driver::run_compiler::{closure#1}::{closure#2}
             at ./compiler/rustc_driver/src/lib.rs:357:13
  56: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
             at ./compiler/rustc_interface/src/queries.rs:377:19
  57: rustc_driver::run_compiler::{closure#1}
             at ./compiler/rustc_driver/src/lib.rs:308:22
  58: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}
             at ./compiler/rustc_interface/src/interface.rs:327:21
  59: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
             at ./compiler/rustc_span/src/lib.rs:1007:5
  60: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}
             at ./compiler/rustc_interface/src/interface.rs:321:13
  61: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
             at /home/matthias/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  62: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}>
             at ./compiler/rustc_span/src/lib.rs:111:5
  63: rustc_interface::util::run_in_thread_pool_with_globals::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}::{closure#0}
             at ./compiler/rustc_interface/src/util.rs:145:38
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.67.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type rlib -C opt-level=3 -C embed-bitcode=no -C debuginfo=1 -C debug-assertions=on -Z unstable-options -C target-cpu=native -C symbol-mangling-version=legacy -Z unstable-options -Z unstable-options -Z macro-backtrace -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C split-debuginfo=off -Z save-analysis -C prefer-dynamic -C embed-bitcode=yes -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo -Z force-unstable-if-unmarked

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `rustc-std-workspace-core`
Build completed unsuccessfully in 0:00:01
```

</p>
</details>