Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dwrensha opened this issue Oct 14, 2021 · 3 comments · Fixed by #111020 or #117246
Closed

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

dwrensha opened this issue Oct 14, 2021 · 3 comments · Fixed by #111020 or #117246
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dwrensha
Copy link
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
@dwrensha dwrensha added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 14, 2021
@dwrensha
Copy link
Contributor Author

dwrensha commented Oct 14, 2021

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
Copy link
Contributor Author

#69340 is where this regressed.
cc @Centril

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2021
@matthiaskrgr
Copy link
Member

another one

struct S0<T>(T);
impl<T> S0<T> {
    fn foo() {
        Self(0);
        const C: S0<u8> = Self(0);
    }
}

@bors bors closed this as completed in 1187ce7 May 4, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 17, 2023
…nkov

Revert "Validate resolution for SelfCtor too."

This reverts commit 8345340.

That PR introduced a breaking change.

Fixes rust-lang#111541
Reopens rust-lang#89868

r? `@petrochenkov`
@cjgillot cjgillot reopened this May 17, 2023
estebank added a commit to estebank/rust that referenced this issue Oct 26, 2023
estebank added a commit to estebank/rust that referenced this issue Oct 26, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 27, 2023
Fix ICE: Restrict param constraint suggestion

When encountering an associated item with a type param that could be constrained, do not look at the parent item if the type param comes from the associated item.

Fix rust-lang#117209, fix rust-lang#89868.
@bors bors closed this as completed in 7449478 Oct 27, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 27, 2023
Rollup merge of rust-lang#117246 - estebank:issue-117209, r=petrochenkov

Fix ICE: Restrict param constraint suggestion

When encountering an associated item with a type param that could be constrained, do not look at the parent item if the type param comes from the associated item.

Fix rust-lang#117209, fix rust-lang#89868.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
4 participants