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 2 out of range for slice of length 1 #119435

Closed
Doremisolatido opened this issue Dec 30, 2023 · 3 comments
Closed

range start index 2 out of range for slice of length 1 #119435

Doremisolatido opened this issue Dec 30, 2023 · 3 comments
Labels
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.

Comments

@Doremisolatido
Copy link

Code

use std::ops::Index;
pub struct v4;
pub trait v7: Index<v4> + Index<v4> {}

pub trait v0 {
type v2: v7;
fn v3(&self) -> &Self::v2;
}
pub fn v1(v8: &impl v0) {
let v3 = v8.v3();
1&v3[v4];
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (95613d1b2 2023-12-29)
binary: rustc
commit-hash: 95613d1b23e2fc01a17f25a3221cdf01730305f9
commit-date: 2023-12-29
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Error output

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs:895:93:
range start index 2 out of range for slice of length 1

Backtrace

stack backtrace:
   0:     0x7fe76a132c7f - std::backtrace::Backtrace::create::h7e7f3c9b259c273e
   1:     0x7fe76a132bc0 - std::backtrace::Backtrace::force_capture::h44ed6bb72613ec4f
   2:     0x7fe76acccd81 - <alloc[702bbbba8ddb1c40]::boxed::Box<rustc_driver_impl[3848e42bde629490]::install_ice_hook::{closure#0}> as core[5a93a61fb5462620]::ops::function::Fn<(&dyn for<'a, 'b> core[5a93a61fb5462620]::ops::function::Fn<(&'a core[5a93a61fb5462620]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[5a93a61fb5462620]::marker::Sync + core[5a93a61fb5462620]::marker::Send, &core[5a93a61fb5462620]::panic::panic_info::PanicInfo)>>::call
   3:     0x7fe76a15ddce - std::panicking::rust_panic_with_hook::h5c31b7690c6487bb
   4:     0x7fe76a105aea - std::panicking::begin_panic_handler::{{closure}}::h2341619f217c339b
   5:     0x7fe76a104cc6 - std::sys_common::backtrace::__rust_end_short_backtrace::hfb8fd31c113ec448
   6:     0x7fe76a15d9a0 - rust_begin_unwind
   7:     0x7fe76a0f9ed5 - core::panicking::panic_fmt::hfa4a29379eb97652
   8:     0x7fe76a0fa5b2 - core::slice::index::slice_start_index_len_fail::hdd93101d6f48fc61
   9:     0x7fe76f27ac9a - <core[5a93a61fb5462620]::iter::adapters::map::Map<itertools[f69b98832f8c49ef]::zip_longest::ZipLongest<core[5a93a61fb5462620]::iter::adapters::rev::Rev<core[5a93a61fb5462620]::iter::adapters::enumerate::Enumerate<alloc[702bbbba8ddb1c40]::vec::into_iter::IntoIter<(rustc_middle[5cfea21eb42abf21]::ty::Ty, alloc[702bbbba8ddb1c40]::vec::Vec<rustc_infer[2047ad5c92e6ef35]::traits::Obligation<rustc_middle[5cfea21eb42abf21]::ty::Predicate>>)>>>, core[5a93a61fb5462620]::iter::adapters::rev::Rev<core[5a93a61fb5462620]::iter::adapters::enumerate::Enumerate<alloc[702bbbba8ddb1c40]::vec::into_iter::IntoIter<(rustc_middle[5cfea21eb42abf21]::ty::Ty, alloc[702bbbba8ddb1c40]::vec::Vec<rustc_infer[2047ad5c92e6ef35]::traits::Obligation<rustc_middle[5cfea21eb42abf21]::ty::Predicate>>)>>>>, <rustc_infer[2047ad5c92e6ef35]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[74b3de977a68ba9a]::traits::error_reporting::suggestions::TypeErrCtxtExt>::suggest_dereferences::{closure#2}> as core[5a93a61fb5462620]::iter::traits::double_ended::DoubleEndedIterator>::try_rfold::<(), core[5a93a61fb5462620]::iter::traits::iterator::Iterator::find_map::check<((usize, (rustc_middle[5cfea21eb42abf21]::ty::Ty, alloc[702bbbba8ddb1c40]::vec::Vec<rustc_infer[2047ad5c92e6ef35]::traits::Obligation<rustc_middle[5cfea21eb42abf21]::ty::Predicate>>)), (usize, (rustc_middle[5cfea21eb42abf21]::ty::Ty, alloc[702bbbba8ddb1c40]::vec::Vec<rustc_infer[2047ad5c92e6ef35]::traits::Obligation<rustc_middle[5cfea21eb42abf21]::ty::Predicate>>))), (core[5a93a61fb5462620]::option::Option<usize>, core[5a93a61fb5462620]::option::Option<usize>), <rustc_infer[2047ad5c92e6ef35]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[74b3de977a68ba9a]::traits::error_reporting::suggestions::TypeErrCtxtExt>::suggest_dereferences::{closure#3}>::{closure#0}, core[5a93a61fb5462620]::ops::control_flow::ControlFlow<(core[5a93a61fb5462620]::option::Option<usize>, core[5a93a61fb5462620]::option::Option<usize>)>>
  10:     0x7fe76f23c300 - <rustc_infer[2047ad5c92e6ef35]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[74b3de977a68ba9a]::traits::error_reporting::suggestions::TypeErrCtxtExt>::suggest_dereferences
  11:     0x7fe76f25a139 - <rustc_infer[2047ad5c92e6ef35]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[74b3de977a68ba9a]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  12:     0x7fe76f26803c - <rustc_infer[2047ad5c92e6ef35]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[74b3de977a68ba9a]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  13:     0x7fe76f2562b1 - <rustc_infer[2047ad5c92e6ef35]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[74b3de977a68ba9a]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  14:     0x7fe76da9ab34 - <rustc_hir_typeck[f85c55eb1a0ed5ef]::fn_ctxt::FnCtxt>::type_inference_fallback
  15:     0x7fe76db8f575 - rustc_hir_typeck[f85c55eb1a0ed5ef]::typeck
  16:     0x7fe76ebd034c - rustc_query_impl[9b35dd15aaf9abd8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9b35dd15aaf9abd8]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5cfea21eb42abf21]::query::erase::Erased<[u8; 8usize]>>
  17:     0x7fe76ecaf9bc - <rustc_query_impl[9b35dd15aaf9abd8]::query_impl::typeck::dynamic_query::{closure#2} as core[5a93a61fb5462620]::ops::function::FnOnce<(rustc_middle[5cfea21eb42abf21]::ty::context::TyCtxt, rustc_span[ab2f26c556f2ed60]::def_id::LocalDefId)>>::call_once
  18:     0x7fe76ef20734 - rustc_query_system[69e59372f3794ffc]::query::plumbing::try_execute_query::<rustc_query_impl[9b35dd15aaf9abd8]::DynamicConfig<rustc_query_system[69e59372f3794ffc]::query::caches::VecCache<rustc_span[ab2f26c556f2ed60]::def_id::LocalDefId, rustc_middle[5cfea21eb42abf21]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9b35dd15aaf9abd8]::plumbing::QueryCtxt, false>
  19:     0x7fe76ed29296 - rustc_query_impl[9b35dd15aaf9abd8]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7fe76ddbcf2e - <rustc_middle[5cfea21eb42abf21]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[4d3f4f48a28512de]::check_crate::{closure#7}>::{closure#0}
  21:     0x7fe76de4c0cc - rustc_hir_analysis[4d3f4f48a28512de]::check_crate
  22:     0x7fe76ae63910 - rustc_interface[56f8a183bbb3a352]::passes::analysis
  23:     0x7fe76ebd03ba - rustc_query_impl[9b35dd15aaf9abd8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9b35dd15aaf9abd8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5cfea21eb42abf21]::query::erase::Erased<[u8; 1usize]>>
  24:     0x7fe76ec8b128 - <rustc_query_impl[9b35dd15aaf9abd8]::query_impl::analysis::dynamic_query::{closure#2} as core[5a93a61fb5462620]::ops::function::FnOnce<(rustc_middle[5cfea21eb42abf21]::ty::context::TyCtxt, ())>>::call_once
  25:     0x7fe76ee6dc9c - rustc_query_system[69e59372f3794ffc]::query::plumbing::try_execute_query::<rustc_query_impl[9b35dd15aaf9abd8]::DynamicConfig<rustc_query_system[69e59372f3794ffc]::query::caches::SingleCache<rustc_middle[5cfea21eb42abf21]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[9b35dd15aaf9abd8]::plumbing::QueryCtxt, false>
  26:     0x7fe76ee35393 - rustc_query_impl[9b35dd15aaf9abd8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7fe76acb14fb - <rustc_middle[5cfea21eb42abf21]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[3848e42bde629490]::run_compiler::{closure#0}::{closure#0}::{closure#3}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>
  28:     0x7fe76acf4540 - <rustc_interface[56f8a183bbb3a352]::interface::Compiler>::enter::<rustc_driver_impl[3848e42bde629490]::run_compiler::{closure#0}::{closure#0}, core[5a93a61fb5462620]::result::Result<core[5a93a61fb5462620]::option::Option<rustc_interface[56f8a183bbb3a352]::queries::Linker>, rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>
  29:     0x7fe76acce48d - rustc_span[ab2f26c556f2ed60]::set_source_map::<core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>, rustc_interface[56f8a183bbb3a352]::interface::run_compiler<core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>, rustc_driver_impl[3848e42bde629490]::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
  30:     0x7fe76acbffb3 - <scoped_tls[d5e14e9d6ff3365]::ScopedKey<rustc_span[ab2f26c556f2ed60]::SessionGlobals>>::set::<rustc_interface[56f8a183bbb3a352]::util::run_in_thread_pool_with_globals<rustc_interface[56f8a183bbb3a352]::interface::run_compiler<core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>, rustc_driver_impl[3848e42bde629490]::run_compiler::{closure#0}>::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>
  31:     0x7fe76acd8c79 - std[dac88b72510f1e89]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[56f8a183bbb3a352]::util::run_in_thread_with_globals<rustc_interface[56f8a183bbb3a352]::util::run_in_thread_pool_with_globals<rustc_interface[56f8a183bbb3a352]::interface::run_compiler<core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>, rustc_driver_impl[3848e42bde629490]::run_compiler::{closure#0}>::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>
  32:     0x7fe76acb5091 - <<std[dac88b72510f1e89]::thread::Builder>::spawn_unchecked_<rustc_interface[56f8a183bbb3a352]::util::run_in_thread_with_globals<rustc_interface[56f8a183bbb3a352]::util::run_in_thread_pool_with_globals<rustc_interface[56f8a183bbb3a352]::interface::run_compiler<core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>, rustc_driver_impl[3848e42bde629490]::run_compiler::{closure#0}>::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5a93a61fb5462620]::result::Result<(), rustc_span[ab2f26c556f2ed60]::ErrorGuaranteed>>::{closure#1} as core[5a93a61fb5462620]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fe76a118875 - std::sys::unix::thread::Thread::new::thread_start::ha609650cad154dd5
  34:     0x7fe769e94ac3 - start_thread
                               at ./nptl/pthread_create.c:442:8
  35:     0x7fe769f26660 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  36:                0x0 - <unknown>


rustc version: 1.77.0-nightly (95613d1b2 2023-12-29)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `v1`
#1 [analysis] running analysis passes on this crate
end of query stack

@Doremisolatido Doremisolatido 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 Dec 30, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 30, 2023
@darklyspaced
Copy link
Contributor

bisected to #118431, cc @sjwang05

@Luk-ESC
Copy link
Contributor

Luk-ESC commented Dec 30, 2023

Minimized:

use std::ops::Index;

pub fn function(arg: impl Index<()>) {
    42 & arg[()];
}

@fmease
Copy link
Member

fmease commented Dec 30, 2023

Closing as dupe of #119352.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 30, 2023
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. 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
Development

No branches or pull requests

6 participants