Skip to content

ICE: len is 1 but index is 1: rustc_middle/src/ty/subst.rs #94822

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

fn a() -> bool {
 for i in 0..80*25 {
       || {};
 }
#[lang = "sized"]
trait A {}
}

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (458262b13 2022-03-09)
binary: rustc
commit-hash: 458262b1315e0de7be940fe95e111bb045e4a2a4
commit-date: 2022-03-09
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

error[E0658]: language items are subject to change
 --> icemaker_63031.rs:5:1
  |
5 | #[lang = "sized"]
  | ^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(lang_items)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `icemaker_63031`
 --> icemaker_63031.rs:7:2
  |
7 | }
  |  ^ consider adding a `main` function to `icemaker_63031.rs`

error[E0152]: found duplicate lang item `sized`
 --> icemaker_63031.rs:6:1
  |
6 | trait A {}
  | ^^^^^^^^^^
  |
  = note: the lang item is first defined in crate `core` (which `std` depends on)
  = note: first definition in `core` loaded from /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0e3656b1fda5fd7b.rlib
  = note: second definition in the local crate (`icemaker_63031`)

error[E0277]: the size for values of type `{integer}` cannot be known at compilation time
  --> icemaker_63031.rs:2:11
   |
2  |  for i in 0..80*25 {
   |           ^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `{integer}`
note: required by a bound in `std::ops::Range`
  --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/range.rs:80:18
   |
80 | pub struct Range<Idx> {
   |                  ^^^ required by this bound in `std::ops::Range`

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/compiler/rustc_middle/src/ty/subst.rs:364:43
Backtrace


thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/compiler/rustc_middle/src/ty/subst.rs:364:43
stack backtrace:
   0:     0x7f264de9da6c - std::backtrace_rs::backtrace::libunwind::trace::h46c3491033e3df9f
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f264de9da6c - std::backtrace_rs::backtrace::trace_unsynchronized::h4ab169bbb354c187
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f264de9da6c - std::sys_common::backtrace::_print_fmt::hc15ef2dc9a287243
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f264de9da6c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h501b36300ab7e9cf
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f264def756c - core::fmt::write::hdf95afd13c610d33
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f264de8e5d1 - std::io::Write::write_fmt::h0d82f708e53862e9
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/io/mod.rs:1655:15
   6:     0x7f264dea0ad5 - std::sys_common::backtrace::_print::h01ef9da1bf4e707e
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f264dea0ad5 - std::sys_common::backtrace::print::h1e9c977feca8e5bd
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f264dea0ad5 - std::panicking::default_hook::{{closure}}::hbef663e6aac7b136
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/panicking.rs:295:22
   9:     0x7f264dea0778 - std::panicking::default_hook::h640314fcce137ca1
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/panicking.rs:314:9
  10:     0x7f264e6c5591 - rustc_driver[2a0ca96018d9e466]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f264dea1221 - std::panicking::rust_panic_with_hook::h5b324d4fa263a7f9
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/panicking.rs:702:17
  12:     0x7f264dea1057 - std::panicking::begin_panic_handler::{{closure}}::h737c0d8ec3d22f87
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/panicking.rs:588:13
  13:     0x7f264de9df24 - std::sys_common::backtrace::__rust_end_short_backtrace::h19199a581de22779
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f264dea0d89 - rust_begin_unwind
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/panicking.rs:584:5
  15:     0x7f264de64a63 - core::panicking::panic_fmt::h40bd402b41242006
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/core/src/panicking.rs:143:14
  16:     0x7f264de649a2 - core::panicking::panic_bounds_check::ha853e9ef8305a2eb
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/core/src/panicking.rs:84:5
  17:     0x7f264f492f0a - <rustc_infer[6830dc6826b3da3]::infer::InferCtxt as rustc_trait_selection[9870cae3a21cea22]::traits::error_reporting::suggestions::InferCtxtExt>::suggest_floating_point_literal
  18:     0x7f264f496fa3 - <rustc_infer[6830dc6826b3da3]::infer::InferCtxt as rustc_trait_selection[9870cae3a21cea22]::traits::error_reporting::InferCtxtExt>::report_selection_error
  19:     0x7f264f49e06b - <rustc_infer[6830dc6826b3da3]::infer::InferCtxt as rustc_trait_selection[9870cae3a21cea22]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  20:     0x7f264f4936bd - <rustc_infer[6830dc6826b3da3]::infer::InferCtxt as rustc_trait_selection[9870cae3a21cea22]::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  21:     0x7f264fa614d9 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_overloaded_binop
  22:     0x7f264fa60943 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_binop
  23:     0x7f264fa7023a - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_kind
  24:     0x7f264fa44002 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x7f264fa71c9b - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_kind
  26:     0x7f264fa44002 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27:     0x7f264fa57db8 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_argument_types
  28:     0x7f264fa3bb06 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::confirm_builtin_call
  29:     0x7f264fa38590 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_call
  30:     0x7f264fa6fd08 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_kind
  31:     0x7f264fa44002 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  32:     0x7f26507786e5 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::demand_scrutinee_type
  33:     0x7f264fa6c869 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_match
  34:     0x7f264fa710de - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_kind
  35:     0x7f264fa44002 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36:     0x7f264fa71ef5 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_kind
  37:     0x7f264fa44002 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  38:     0x7f264fa5bd3a - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_stmt
  39:     0x7f264fa5cbda - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  40:     0x7f264fa6fd3e - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_kind
  41:     0x7f264fa44002 - <rustc_typeck[7ae584030a131cc9]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42:     0x7f264fb6f9b7 - rustc_typeck[7ae584030a131cc9]::check::check::check_fn
  43:     0x7f264fae032d - <rustc_infer[6830dc6826b3da3]::infer::InferCtxtBuilder>::enter::<&rustc_middle[196f2c11c2e6806c]::ty::context::TypeckResults, <rustc_typeck[7ae584030a131cc9]::check::inherited::InheritedBuilder>::enter<rustc_typeck[7ae584030a131cc9]::check::typeck_with_fallback<rustc_typeck[7ae584030a131cc9]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[196f2c11c2e6806c]::ty::context::TypeckResults>::{closure#0}>
  44:     0x7f264fac73bf - rustc_typeck[7ae584030a131cc9]::check::typeck
  45:     0x7f264ff80377 - rustc_query_system[68aa2a3da4535f14]::query::plumbing::try_execute_query::<rustc_query_impl[a379114de9839269]::plumbing::QueryCtxt, rustc_query_system[68aa2a3da4535f14]::query::caches::DefaultCache<rustc_span[729ef1fe2cb7b415]::def_id::LocalDefId, &rustc_middle[196f2c11c2e6806c]::ty::context::TypeckResults>>
  46:     0x7f26500601d8 - <rustc_query_impl[a379114de9839269]::Queries as rustc_middle[196f2c11c2e6806c]::ty::query::QueryEngine>::typeck
  47:     0x7f264fac7586 - rustc_typeck[7ae584030a131cc9]::check::typeck
  48:     0x7f264ff80377 - rustc_query_system[68aa2a3da4535f14]::query::plumbing::try_execute_query::<rustc_query_impl[a379114de9839269]::plumbing::QueryCtxt, rustc_query_system[68aa2a3da4535f14]::query::caches::DefaultCache<rustc_span[729ef1fe2cb7b415]::def_id::LocalDefId, &rustc_middle[196f2c11c2e6806c]::ty::context::TypeckResults>>
  49:     0x7f26500601d8 - <rustc_query_impl[a379114de9839269]::Queries as rustc_middle[196f2c11c2e6806c]::ty::query::QueryEngine>::typeck
  50:     0x7f264fb263dc - <rustc_middle[196f2c11c2e6806c]::hir::map::Map>::par_body_owners::<rustc_typeck[7ae584030a131cc9]::check::typeck_item_bodies::{closure#0}>
  51:     0x7f26507b9e1c - rustc_typeck[7ae584030a131cc9]::check::typeck_item_bodies
  52:     0x7f2650a04877 - rustc_query_system[68aa2a3da4535f14]::query::plumbing::try_execute_query::<rustc_query_impl[a379114de9839269]::plumbing::QueryCtxt, rustc_query_system[68aa2a3da4535f14]::query::caches::DefaultCache<(), ()>>
  53:     0x7f2650a2b241 - rustc_query_system[68aa2a3da4535f14]::query::plumbing::get_query::<rustc_query_impl[a379114de9839269]::queries::typeck_item_bodies, rustc_query_impl[a379114de9839269]::plumbing::QueryCtxt>
  54:     0x7f26507ba83a - rustc_typeck[7ae584030a131cc9]::check_crate
  55:     0x7f26505484c7 - rustc_interface[918eb7e942aa3a9d]::passes::analysis
  56:     0x7f26509fa58e - rustc_query_system[68aa2a3da4535f14]::query::plumbing::try_execute_query::<rustc_query_impl[a379114de9839269]::plumbing::QueryCtxt, rustc_query_system[68aa2a3da4535f14]::query::caches::DefaultCache<(), core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>>
  57:     0x7f2650a39aae - rustc_query_system[68aa2a3da4535f14]::query::plumbing::get_query::<rustc_query_impl[a379114de9839269]::queries::analysis, rustc_query_impl[a379114de9839269]::plumbing::QueryCtxt>
  58:     0x7f26505266a4 - <rustc_interface[918eb7e942aa3a9d]::passes::QueryContext>::enter::<rustc_driver[2a0ca96018d9e466]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>
  59:     0x7f26505047c8 - <rustc_interface[918eb7e942aa3a9d]::interface::Compiler>::enter::<rustc_driver[2a0ca96018d9e466]::run_compiler::{closure#1}::{closure#2}, core[a3fb8d670b17dca4]::result::Result<core[a3fb8d670b17dca4]::option::Option<rustc_interface[918eb7e942aa3a9d]::queries::Linker>, rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>
  60:     0x7f265051734f - rustc_span[729ef1fe2cb7b415]::with_source_map::<core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>, rustc_interface[918eb7e942aa3a9d]::interface::create_compiler_and_run<core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>, rustc_driver[2a0ca96018d9e466]::run_compiler::{closure#1}>::{closure#1}>
  61:     0x7f26505054a4 - rustc_interface[918eb7e942aa3a9d]::interface::create_compiler_and_run::<core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>, rustc_driver[2a0ca96018d9e466]::run_compiler::{closure#1}>
  62:     0x7f2650503592 - <scoped_tls[4c2cab578bca6f50]::ScopedKey<rustc_span[729ef1fe2cb7b415]::SessionGlobals>>::set::<rustc_interface[918eb7e942aa3a9d]::interface::run_compiler<core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>, rustc_driver[2a0ca96018d9e466]::run_compiler::{closure#1}>::{closure#0}, core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>
  63:     0x7f265050186f - std[787e7261aab00ccc]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[918eb7e942aa3a9d]::util::run_in_thread_pool_with_globals<rustc_interface[918eb7e942aa3a9d]::interface::run_compiler<core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>, rustc_driver[2a0ca96018d9e466]::run_compiler::{closure#1}>::{closure#0}, core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>::{closure#0}, core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>
  64:     0x7f2650501b69 - <<std[787e7261aab00ccc]::thread::Builder>::spawn_unchecked_<rustc_interface[918eb7e942aa3a9d]::util::run_in_thread_pool_with_globals<rustc_interface[918eb7e942aa3a9d]::interface::run_compiler<core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>, rustc_driver[2a0ca96018d9e466]::run_compiler::{closure#1}>::{closure#0}, core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>::{closure#0}, core[a3fb8d670b17dca4]::result::Result<(), rustc_errors[ffe98a503933c183]::ErrorGuaranteed>>::{closure#1} as core[a3fb8d670b17dca4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  65:     0x7f264deab343 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5c266408d0190ecf
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/alloc/src/boxed.rs:1854:9
  66:     0x7f264deab343 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9024b13a351d4d0c
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/alloc/src/boxed.rs:1854:9
  67:     0x7f264deab343 - std::sys::unix::thread::Thread::new::thread_start::hd9882aa648bba6a5
                               at /rustc/458262b1315e0de7be940fe95e111bb045e4a2a4/library/std/src/sys/unix/thread.rs:108:17
  68:     0x7f264dc835c2 - start_thread
  69:     0x7f264dd08584 - __clone
  70:                0x0 - <unknown>

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.61.0-nightly (458262b13 2022-03-09) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `a`
#1 [typeck] type-checking `a::{closure#0}`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

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

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

    Development

    No branches or pull requests

    Issue actions