Skip to content

task 'rustc' failed at 'index out of bounds: the len is 12 but the index is 12' #15170

@ghost

Description

I'm working through the tutorial, and managed to get a compilation error.

Tested with 0.11.0-pre-nightly (f8c9aec 2014-06-19 05:21:16 +0000) and rustc 0.11.0-pre (a490871a6c3fae9017a6402fcf911d05dcf1d013 2014-06-29 21:41:45 +0000)

OS is Manjaro Linux 64bit

enum List<T> {
    Cons(T, Box<List<T>>),
    Nil
}

fn main() {

    let xs = Cons(5, box Cons(10, box Nil));
    let ys = Cons(5, box Cons(10, box Nil));

    // The methods below are part of the PartialEq trait,
    // which we implemented on our linked list.
    assert!(xs,eq(&ys));

}

fn eq<T: PartialEq> (xs:&List<T>, ys: &List<T>) -> bool {
    // Match on the next node in both lists.
    match (xs, ys) {
        // If we have reached the end of both lists, they are equal.
        (&Nil, &Nil) => true,
        // If the current elements of both lists are equal, keep going.
        (&Cons(ref x, box ref next_xs), &Cons(ref y, box ref next_ys))
            if x == y => eq(next_xs, next_ys),
        // If the current elements are not equal, the lists are not equal.
        _ => false
    }
}
<std macros>:8:12: 13:15 error: cannot apply unary operator `!` to type `List<<generic integer #1>>`
<std macros>:8         if !$cond {
<std macros>:9             fail!($($arg),+)
<std macros>:10         }
<std macros>:11     );
<std macros>:12 )
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'index out of bounds: the len is 12 but the index is 12', /home/kingsley/Projects/Repositories/rust/src/libsyntax/lib.rs:1

stack backtrace:
   1:     0x7fa6197c8e60 - rt::backtrace::imp::write::h416f5febecf481e0UGp::v0.11.0.pre
   2:     0x7fa6197cf990 - failure::on_fail::hd9dabba9151477e991p::v0.11.0.pre
   3:     0x7fa61b918b10 - unwind::begin_unwind_inner::h48ee93a0d7f13eaccZd::v0.11.0.pre
   4:     0x7fa61b9185c0 - unwind::begin_unwind_fmt::h6e98fd5ad319e451FWd::v0.11.0.pre
   5:     0x7fa61b918580 - rust_begin_unwind
   6:     0x7fa61b9632c0 - failure::begin_unwind::hee56801fc34bd58cX2v::v0.11.0.pre
   7:     0x7fa61b964cd0 - failure::fail_bounds_check::h2c22b5b93c6cdf7090v::v0.11.0.pre
   8:     0x7fa61ad6e9a0 - codemap::FileMap::get_line::ha6ed00e959e41056RDd::v0.11.0.pre
   9:     0x7fa61ad6a410 - diagnostic::emit::h93a2a5b799d5960c0uc::v0.11.0.pre
  10:     0x7fa61ad656b0 - diagnostic::EmitterWriter.Emitter::emit::haaf5e62e051041109qc::v0.11.0.pre
  11:     0x7fa61ad63c40 - diagnostic::Handler::emit::he4f3014008107a63kec::v0.11.0.pre
  12:     0x7fa61ad62f10 - diagnostic::SpanHandler::span_err::h7b21ffeef41be1b3Q4b::v0.11.0.pre
  13:     0x7fa61c519350 - middle::typeck::infer::InferCtxt<'a>::type_error_message_str_with_expected::h34f02c25bcd032bd6Kw::v0.11.0.pre
  14:     0x7fa61c5c9810 - middle::typeck::infer::InferCtxt<'a>::type_error_message::hdf83fa3337b86f10OSw::v0.11.0.pre
  15:     0x7fa61c5d7cc0 - middle::typeck::check::check_expr_with_unifier::check_user_unop::closure.92651
  16:     0x7fa61c5d5450 - middle::typeck::check::check_expr_with_unifier::lookup_op_method::he5adda6db52a2c77SFf::v0.11.0.pre
  17:     0x7fa61c5d7950 - middle::typeck::check::check_expr_with_unifier::check_user_unop::h2b1f451b9b0268c8HUf::v0.11.0.pre
  18:     0x7fa61c5cd4c0 - middle::typeck::check::check_expr_with_unifier::hbb12d5ac9878a1467rf::v0.11.0.pre
  19:     0x7fa61c5cd4c0 - middle::typeck::check::check_expr_with_unifier::hbb12d5ac9878a1467rf::v0.11.0.pre
  20:     0x7fa61c5e8ce0 - middle::typeck::check::check_stmt::h616240c5bb924a2f1ih::v0.11.0.pre
  21:     0x7fa61c5a2f70 - middle::typeck::check::check_block_with_expected::hd46188bf10bca4c0cnh::v0.11.0.pre
  22:     0x7fa61c59e670 - middle::typeck::check::check_fn::h6b698d4a809e2272jUc::v0.11.0.pre
  23:     0x7fa61c59e430 - middle::typeck::check::check_bare_fn::h5e40c317ce0ca95bRJc::v0.11.0.pre
  24:     0x7fa61c597e80 - middle::typeck::check::check_item::h42f9fe4be6f302635gd::v0.11.0.pre
  25:     0x7fa61c59e230 - middle::typeck::check::check_item_types::habfcdf0c64ccccdf9Ic::v0.11.0.pre
  26:     0x7fa61c71b810 - middle::typeck::check_crate::h27c2b9882055e043SJC::v0.11.0.pre
  27:     0x7fa61cb93c80 - driver::driver::phase_3_run_analysis_passes::h3d00644185dbaa4f84p::v0.11.0.pre
  28:     0x7fa61cb8f230 - driver::driver::compile_input::h3cdb3a46225f37066Rp::v0.11.0.pre
  29:     0x7fa61cc5bfe0 - driver::run_compiler::h0b665bca7c20427c5Bs::v0.11.0.pre
  30:     0x7fa61cc5bef0 - driver::main_args::closure.117254
  31:     0x7fa61cc71010 - task::TaskBuilder<S>::try_future::closure.118394
  32:     0x7fa61cc70c30 - task::TaskBuilder<S>::spawn_internal::closure.118371
  33:     0x7fa61bc76cc0 - task::spawn_opts::closure.7461
  34:     0x7fa61b979170 - rust_try
  35:     0x7fa61b915120 - unwind::try::hf096e195bac714bbBNd::v0.11.0.pre
  36:     0x7fa61b914e00 - task::Task::run::he089a676a6c62e49XYc::v0.11.0.pre
  37:     0x7fa61bc76a80 - task::spawn_opts::closure.7407
  38:     0x7fa61b9179c0 - thread::thread_start::he5b88e576f787f6dvld::v0.11.0.pre
  39:     0x7fa61923e060 - start_thread
  40:     0x7fa61b5df489 - __clone
  41:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions