Skip to content

ICE calling an unboxed closure with the wrong number of parameters inside another closure #16939

Closed
@FreeFull

Description

@FreeFull

This code reproduces the ICE.

#![feature(overloaded_calls)]

fn foo<F: |&:|> (f: F) {
    |t| f(t);
}

fn main() { }

Note that adding an argument to the type signature or removing the t argument to the closure both make the ICE go away, and make the code compile.

freefull@freefull-hp ~/c/m/r/ice> rustc main.rs 
main.rs:4:9: 4:13 error: this function takes 0 parameters but 1 parameter was supplied [E0058]
main.rs:4     |t| f(t);
                  ^~~~
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 0 but the index is 0', /build/rust-git/src/rust/src/librustc/lib.rs:1

stack backtrace:
   1:     0x7f291724af70 - rt::backtrace::imp::write::hc08b75d6b2e612bbOLq
   2:     0x7f291724e110 - <unknown>
   3:     0x7f291b7b3ee0 - unwind::begin_unwind_inner::h8a158fdde916465bZ2d
   4:     0x7f291b7b3a40 - unwind::begin_unwind_fmt::h938e0530fc34f285p0d
   5:     0x7f291b7b3a00 - rust_begin_unwind
   6:     0x7f291b7f5820 - failure::begin_unwind::h3cbfe96986aeabc32mk
   7:     0x7f291b7f56d0 - failure::fail_bounds_check::h99472db43b15994cYjk
   8:     0x7f291c3d0410 - <unknown>
   9:     0x7f291c3cf2d0 - <unknown>
  10:     0x7f291c3ce270 - <unknown>
  11:     0x7f291c3d2890 - <unknown>
  12:     0x7f291c395590 - <unknown>
  13:     0x7f291c3907f0 - <unknown>
  14:     0x7f291c3df470 - <unknown>
  15:     0x7f291c3d2890 - <unknown>
  16:     0x7f291c42d720 - middle::typeck::check::check_stmt::hf4ab28118bf02286f4Z
  17:     0x7f291c395590 - <unknown>
  18:     0x7f291c3907f0 - <unknown>
  19:     0x7f291c3905c0 - <unknown>
  20:     0x7f291c388fb0 - middle::typeck::check::check_item::ha751ce7e2c7474b4jcV
  21:     0x7f291c3902f0 - middle::typeck::check::check_item_types::he822f6291bc1bc16zvU
  22:     0x7f291bdf6dc0 - <unknown>
  23:     0x7f291c5b0d70 - middle::typeck::check_crate::hd1adfbe05037b78eLYm
  24:     0x7f291c670ba0 - driver::driver::phase_3_run_analysis_passes::h9040b892d1edd3255DB
  25:     0x7f291c66c6a0 - driver::driver::compile_input::h1532034c5b784c18SpB
  26:     0x7f291c7003f0 - <unknown>
  27:     0x7f291c700300 - <unknown>
  28:     0x7f291c712f00 - <unknown>
  29:     0x7f291c712d00 - <unknown>
  30:     0x7f291bb05d30 - <unknown>
  31:     0x7f291b803160 - <unknown>
  32:     0x7f291b803150 - rust_try
  33:     0x7f291b7b16a0 - unwind::try::hd2f49c6ff6b9f247fRd
  34:     0x7f291b7b1500 - task::Task::run::h6ac43dca245b49a092c
  35:     0x7f291bb05a90 - <unknown>
  36:     0x7f291b7b3010 - <unknown>
  37:     0x7f29165e9060 - start_thread
  38:     0x7f291b482489 - __clone
  39:                0x0 - <unknown>

freefull@freefull-hp ~/c/m/r/ice> rustc --version
rustc 0.12.0-pre (0bdac78da 2014-09-01 21:31:00 +0000)

Arch Linux x86-64

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)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