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

range start index 1 out of range for slice of length 0 #98598

Closed
purplg opened this issue Jun 28, 2022 · 8 comments · Fixed by #98610
Closed

range start index 1 out of range for slice of length 0 #98598

purplg opened this issue Jun 28, 2022 · 8 comments · Fixed by #98610
Assignees
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) ❄️ P-medium Medium priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@purplg
Copy link

purplg commented Jun 28, 2022

Code

pub trait Foo {
    type Output: Foo;
    
    fn baz() -> Self::Output;
}

pub struct Bar;

impl Foo for &Bar {
    type Output = Bar;

    fn baz() -> Self::Output {
        Foo::baz();

        Self::Output {}
    }
}

Meta

I reproduced this bug on nightly and master but did not exist on stable or beta.

rustc --version --verbose:

rustc 1.64.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.64.0-dev
LLVM version: 14.0.6
rustc 1.64.0-nightly (c80c4b8fd 2022-06-26)
binary: rustc
commit-hash: c80c4b8fdcf3da69cd483e2fec172c9b1f95842c
commit-date: 2022-06-26
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.5

Error output

thread 'rustc' panicked at 'range start index 1 out of range for slice of length 0', library/core/src/slice/index.rs:52:5
Backtrace

thread 'rustc' panicked at 'range start index 1 out of range for slice of length 0', library/core/src/slice/index.rs:52:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/panicking.rs:142:14
   2: core::slice::index::slice_start_index_len_fail_rt
             at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/slice/index.rs:52:5
   3: core::ops::function::FnOnce::call_once
             at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/ops/function.rs:248:5
   4: core::intrinsics::const_eval_select
             at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/intrinsics.rs:2376:5
   5: core::slice::index::slice_start_index_len_fail
             at /rustc/20a6f3a8a8ce5ae18d06b12cd7904bc5294ca753/library/core/src/slice/index.rs:42:9
   6: <rustc_middle::ty::generics::Generics>::own_substs
   7: <rustc_infer::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir::intravisit::Visitor>::visit_expr
   8: <rustc_infer::infer::error_reporting::need_type_info::FindInferSourceVisitor as rustc_hir::intravisit::Visitor>::visit_expr
   9: <rustc_infer::infer::InferCtxt>::emit_inference_failure_err
  10: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::maybe_report_ambiguity
  11: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  12: <rustc_infer::infer::InferCtxtBuilder>::enter::<&rustc_middle::ty::context::TypeckResults, <rustc_typeck::check::inherited::InheritedBuilder>::enter<rustc_typeck::check::typeck_with_fallback<rustc_typeck::check::typeck::{closure#0}>::{closure#1}, &rustc_middle::ty::context::TypeckResults>::{closure#0}>
  13: rustc_typeck::check::typeck
  14: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>
  15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>
  16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  17: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_typeck::check::typeck_item_bodies::{closure#0}>
  18: rustc_typeck::check::typeck_item_bodies
  19: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), ()>
  20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), ()>>
  21: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  22: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#7}>
  23: rustc_typeck::check_crate
  24: rustc_interface::passes::analysis
  25: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  27: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  28: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  29: <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>>
  30: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  31: <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>>
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.64.0-nightly (20a6f3a8a 2022-06-25) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `<impl at src/lib.rs:9:1: 17:2>::some_function`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0277`.
error: could not compile `rust-bug` due to previous error

Let me know if I can further assist.

@purplg purplg 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 Jun 28, 2022
@Rageking8
Copy link
Contributor

@rustbot label regression-from-stable-to-nightly

@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 28, 2022
@Rageking8
Copy link
Contributor

This also ICEs with a slightly different variant of the code.
1.64.0-nightly
(2022-06-26 c80c4b8)

pub trait Foo {
    type Output: Foo;
    
    fn baz() -> Self::Output;
}

pub struct Bar;

impl Foo for Bar {
    type Output = Bar;

    fn baz() -> Self::Output {
        Foo::baz();

        Self::Output {}
    }
}

However, it does not ICE using stable 1.61.0 or 1.62.0-beta.7 (2022-06-26 747075d).

@apiraino
Copy link
Contributor

apiraino commented Jun 28, 2022

bisection leads to commit e40d5e8, pr #89862

searched nightlies: from nightly-2022-03-21 to nightly-2022-06-28
regressed nightly: nightly-2022-06-04
searched commits: from e714405 to a6b8c69
regressed commit: e40d5e8

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2022-03-21 --regress ice 

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 28, 2022
@compiler-errors
Copy link
Member

cc @lcnr

@lcnr

This comment was marked as outdated.

@rustbot

This comment was marked as outdated.

@lcnr
Copy link
Contributor

lcnr commented Jun 28, 2022

@rustbot claim

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) ❄️ P-medium Medium priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants