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

ICE: range start index 2 out of range for slice of length 1 #119352

Closed
matthiaskrgr opened this issue Dec 27, 2023 · 4 comments · Fixed by #119361
Closed

ICE: range start index 2 out of range for slice of length 1 #119352

matthiaskrgr opened this issue Dec 27, 2023 · 4 comments · Fixed by #119361
Assignees
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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Dec 27, 2023

snippet:

fn serial_init() {
    lolunknown(COM_LCR_WLEN8 & (*"Sized".to_string().into_boxed_str()));
}

Version information

rustc 1.77.0-nightly (ca9ff83f1 2023-12-27)
binary: rustc
commit-hash: ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e
commit-date: 2023-12-27
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0425]: cannot find value `COM_LCR_WLEN8` in this scope
 --> /tmp/icemaker_global_tempdir.7uNXIvlaAV6Z/rustc_testrunner_tmpdir_reporting.Str0Z6Gmtz0Q/mvce.rs:2:16
  |
2 |     lolunknown(COM_LCR_WLEN8 & (*"Sized".to_string().into_boxed_str()));
  |                ^^^^^^^^^^^^^ not found in this scope

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.7uNXIvlaAV6Z/rustc_testrunner_tmpdir_reporting.Str0Z6Gmtz0Q/mvce.rs:3:2
  |
3 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.7uNXIvlaAV6Z/rustc_testrunner_tmpdir_reporting.Str0Z6Gmtz0Q/mvce.rs`

error[E0425]: cannot find function `lolunknown` in this scope
 --> /tmp/icemaker_global_tempdir.7uNXIvlaAV6Z/rustc_testrunner_tmpdir_reporting.Str0Z6Gmtz0Q/mvce.rs:2:5
  |
2 |     lolunknown(COM_LCR_WLEN8 & (*"Sized".to_string().into_boxed_str()));
  |     ^^^^^^^^^^ not found in this scope

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
stack backtrace:
   0:     0x7fb547be9756 - std::backtrace_rs::backtrace::libunwind::trace::he999339051b091b1
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb547be9756 - std::backtrace_rs::backtrace::trace_unsynchronized::h9f78cacd86ef3c7d
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb547be9756 - std::sys_common::backtrace::_print_fmt::h5c2049bdc1f08508
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb547be9756 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdd02066d05dd488e
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb547c3c080 - core::fmt::rt::Argument::fmt::h07dee6933df37465
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb547c3c080 - core::fmt::write::ha16d8ae3c0bc27dc
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb547bdd40f - std::io::Write::write_fmt::h324b94efcec0fb0f
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/io/mod.rs:1810:15
   7:     0x7fb547be9534 - std::sys_common::backtrace::_print::h180e4cd35bfe4d65
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb547be9534 - std::sys_common::backtrace::print::h11fb4e42bbc715d4
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb547bec2c7 - std::panicking::default_hook::{{closure}}::h80aaed4cbdabb91a
  10:     0x7fb547bec029 - std::panicking::default_hook::h502b9a16d472ee07
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/panicking.rs:292:9
  11:     0x7fb544950cfc - std[855c18717e34e1aa]::panicking::update_hook::<alloc[c9845d7f62b03ea1]::boxed::Box<rustc_driver_impl[8fbc4de111867a14]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb547beca16 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3aa4b4d4e29eab1e
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/alloc/src/boxed.rs:2029:9
  13:     0x7fb547beca16 - std::panicking::rust_panic_with_hook::hbddb29b82c27d8de
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/panicking.rs:783:13
  14:     0x7fb547bec762 - std::panicking::begin_panic_handler::{{closure}}::he139ae91aec90704
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/panicking.rs:657:13
  15:     0x7fb547be9c56 - std::sys_common::backtrace::__rust_end_short_backtrace::h3623a41a8c78295c
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fb547bec4c0 - rust_begin_unwind
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/panicking.rs:645:5
  17:     0x7fb547c38785 - core::panicking::panic_fmt::hb165c617d5590abc
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/core/src/panicking.rs:72:14
  18:     0x7fb547c3e992 - core::slice::index::slice_start_index_len_fail_rt::h4ea466071628761d
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/core/src/slice/index.rs:52:5
  19:     0x7fb547c3e992 - core::slice::index::slice_start_index_len_fail::h35439c30e726957c
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/core/src/slice/index.rs:40:9
  20:     0x7fb54545e62c - <rustc_infer[f6bc2f3403a9f908]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[f0efaf6ce0ee3458]::traits::error_reporting::suggestions::TypeErrCtxtExt>::suggest_dereferences
  21:     0x7fb54547fffd - <rustc_infer[f6bc2f3403a9f908]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[f0efaf6ce0ee3458]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  22:     0x7fb5454a76e1 - <rustc_infer[f6bc2f3403a9f908]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[f0efaf6ce0ee3458]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  23:     0x7fb54547b877 - <rustc_infer[f6bc2f3403a9f908]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[f0efaf6ce0ee3458]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  24:     0x7fb54660aac1 - <rustc_hir_typeck[27e83c694fc7bb73]::fn_ctxt::FnCtxt>::type_inference_fallback
  25:     0x7fb545efe3ca - rustc_hir_typeck[27e83c694fc7bb73]::typeck
  26:     0x7fb545efd735 - rustc_query_impl[52c3636fd1c621b8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52c3636fd1c621b8]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[eadc16aa5b2d798c]::query::erase::Erased<[u8; 8usize]>>
  27:     0x7fb545e16003 - rustc_query_system[6816ad35e73f53f7]::query::plumbing::try_execute_query::<rustc_query_impl[52c3636fd1c621b8]::DynamicConfig<rustc_query_system[6816ad35e73f53f7]::query::caches::VecCache<rustc_span[7d331dab010f821e]::def_id::LocalDefId, rustc_middle[eadc16aa5b2d798c]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[52c3636fd1c621b8]::plumbing::QueryCtxt, false>
  28:     0x7fb545e15c90 - rustc_query_impl[52c3636fd1c621b8]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fb54623afaf - <rustc_middle[eadc16aa5b2d798c]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[b169b98e228215e2]::check_crate::{closure#7}>::{closure#0}
  30:     0x7fb5462397a5 - rustc_hir_analysis[b169b98e228215e2]::check_crate
  31:     0x7fb5465548a9 - rustc_interface[d612fcec1432366d]::passes::analysis
  32:     0x7fb5465544dd - rustc_query_impl[52c3636fd1c621b8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52c3636fd1c621b8]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[eadc16aa5b2d798c]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7fb546b9f900 - rustc_query_system[6816ad35e73f53f7]::query::plumbing::try_execute_query::<rustc_query_impl[52c3636fd1c621b8]::DynamicConfig<rustc_query_system[6816ad35e73f53f7]::query::caches::SingleCache<rustc_middle[eadc16aa5b2d798c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[52c3636fd1c621b8]::plumbing::QueryCtxt, false>
  34:     0x7fb546b9f707 - rustc_query_impl[52c3636fd1c621b8]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7fb546c36752 - rustc_interface[d612fcec1432366d]::interface::run_compiler::<core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>, rustc_driver_impl[8fbc4de111867a14]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7fb546bbe706 - std[855c18717e34e1aa]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d612fcec1432366d]::util::run_in_thread_with_globals<rustc_interface[d612fcec1432366d]::util::run_in_thread_pool_with_globals<rustc_interface[d612fcec1432366d]::interface::run_compiler<core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>, rustc_driver_impl[8fbc4de111867a14]::run_compiler::{closure#0}>::{closure#0}, core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>>::{closure#0}, core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>>
  37:     0x7fb546bbe533 - <<std[855c18717e34e1aa]::thread::Builder>::spawn_unchecked_<rustc_interface[d612fcec1432366d]::util::run_in_thread_with_globals<rustc_interface[d612fcec1432366d]::util::run_in_thread_pool_with_globals<rustc_interface[d612fcec1432366d]::interface::run_compiler<core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>, rustc_driver_impl[8fbc4de111867a14]::run_compiler::{closure#0}>::{closure#0}, core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>>::{closure#0}, core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[14b734a3e12aace1]::result::Result<(), rustc_span[7d331dab010f821e]::ErrorGuaranteed>>::{closure#1} as core[14b734a3e12aace1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7fb547bf6945 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6a024772f7810b01
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/alloc/src/boxed.rs:2015:9
  39:     0x7fb547bf6945 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5739f1057fc9bfd8
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/alloc/src/boxed.rs:2015:9
  40:     0x7fb547bf6945 - std::sys::unix::thread::Thread::new::thread_start::hd654374c5da395df
                               at /rustc/ca9ff83f1be558d4ce0a9a49b3d4d25034e5bd1e/library/std/src/sys/unix/thread.rs:108:17
  41:     0x7fb541aaa9eb - <unknown>
  42:     0x7fb541b2e7cc - <unknown>
  43:                0x0 - <unknown>

error: 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.77.0-nightly (ca9ff83f1 2023-12-27) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `serial_init`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0425, E0601.
For more information about an error, try `rustc --explain E0425`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Dec 27, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 27, 2023
@matthiaskrgr matthiaskrgr changed the title ICE: `range start index 2 out of range for slice of length 1 ICE: range start index 2 out of range for slice of length 1 Dec 27, 2023
@matthiaskrgr
Copy link
Member Author

Regression in #118431 cc sjwang05

@sjwang05
Copy link
Contributor

@rustbot claim

@estebank
Copy link
Contributor

estebank commented Dec 27, 2023

@sjwang05 just to jump start, I just checked the contents of inner in the case presented:

 INFO rustc_trait_selection::traits::error_reporting::suggestions inner.trait_ref.args=[str], inner.trait_ref=<str as std::marker::Sized>

I'm checking what breaks in the test suite if we change the slicing to args[1..] (which intuitively makes more sense but am still trying to piece things together). Edit: Ah, yeah, that won't work.

@sjwang05
Copy link
Contributor

sjwang05 commented Dec 27, 2023

Thanks for the help, turns out I could've just used iter().skip(2) instead of slicing all along 🤦. I'll submit the PR once the test suite finishes running locally.

As a side note, do you know why some binops seem to have 3 args? Intuitively it'd make sense to only have 2 args for the lhs and rhs tys--my guess is that the "extra" arg is something effects-related, but I'm not familiar at all with that part of the code.

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

Successfully merging a pull request may close this issue.

5 participants