Skip to content

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0' #89868

@dwrensha

Description

@dwrensha
Contributor

rustc crashes on the following input, found by fuzz_rustc:

struct A<B>(B);
impl<B>A<B>{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::marker::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

Activity

added
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.
on Oct 14, 2021
dwrensha

dwrensha commented on Oct 14, 2021

@dwrensha
ContributorAuthor

cargo-bisect-rustc says:

Regression in nightly-2020-02-29
...
found 7 bors merge commits in the specified range
commit[0] 2020-02-27UTC: Auto merge of #68434 - varkor:astconv-mismatch-error, r=nikomatsakis
commit[1] 2020-02-27UTC: Auto merge of #69513 - tmiasko:revert-checked-unused, r=petrochenkov
commit[2] 2020-02-28UTC: Auto merge of #69534 - Dylan-DPC:rollup-fwa2lip, r=Dylan-DPC
commit[3] 2020-02-28UTC: Auto merge of #68505 - skinny121:canonicalize-const-eval-inputs, r=nikomatsakis
commit[4] 2020-02-28UTC: Auto merge of #68827 - ssomers:btree_navigation_revisited, r=Mark-Simulacrum
commit[5] 2020-02-28UTC: Auto merge of #69148 - estebank:cold-as-ice, r=oli-obk
commit[6] 2020-02-28UTC: Auto merge of #69555 - Centril:rollup-e53lxz4, r=Centril
ERROR: no commits between 6d69cab and 0eb878d within last 167 days

dwrensha

dwrensha commented on Oct 14, 2021

@dwrensha
ContributorAuthor

#69340 is where this regressed.
cc @Centril

matthiaskrgr

matthiaskrgr commented on Apr 22, 2023

@matthiaskrgr
Member

another one

struct S0<T>(T);
impl<T> S0<T> {
    fn foo() {
        Self(0);
        const C: S0<u8> = Self(0);
    }
}
added a commit that references this issue on May 4, 2023

Rollup merge of rust-lang#111020 - cjgillot:validate-self-ctor, r=pet…

1187ce7
added a commit that references this issue on May 17, 2023

Rollup merge of rust-lang#111557 - cjgillot:revert-111020, r=petroche…

ff364b0

6 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @matthiaskrgr@dwrensha@cjgillot@rust-lang-glacier-bot

      Issue actions

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