thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0' · Issue #89868 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@dwrensha

Description

@dwrensha

rustc crashes on the following input, found by fuzz_rustc:

struct A(B); implA{fn d(){fn d(){Self(1)}}}

$ rustc main.rs
error[E0601]: `main` function not found in crate `main`
 --> main.rs:1:1
  |
1 | / struct A<B>(B);
2 | | impl<B>A<B>{fn d(){fn d(){Self(1)}}}
  | |____________________________________^ consider adding a `main` function to `main.rs`

error[E0277]: the size for values of type `B` cannot be known at compilation time
 --> main.rs:2:27
  |
2 | impl<B>A<B>{fn d(){fn d(){Self(1)}}}
  |      -                    ^^^^ doesn't have a size known at compile-time
  |      |
  |      this type parameter needs to be `std:📑:Sized`
  |
note: required by `A`
 --> main.rs:1:1
  |
1 | struct A<B>(B);
  | ^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', compiler/rustc_middle/src/ty/generics.rs:164:14
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.57.0-nightly (d7c97a02d 2021-10-12) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `<impl at main.rs:2:1: 2:37>::d::d`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 2 previous errors