Skip to content

ICE with a wrong notation for an unboxed closure trait: Fn<A, R> #20171

@nodakai

Description

@nodakai
fn f<A, R, F> (_: F) where F: Fn<A, R> {
}

fn main() {
    f(|| ())
}

Confirmed with the Dec 20 snapshot (8443b09 2014-12-20 05:52:18 +0000)

$ RUST_BACKTRACE=1 rustc unboxed-closure-arg-type-tuple.rs                                                                                                                                          
error: internal compiler error: unexpected panic            
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'assertion failed: begin <= end', /home/nodakai/prog/rust-HEAD/src/libcore/str.rs:1999

stack backtrace:
   1:     0x7f6270e39100 - sys::backtrace::write::hd1381419a8907f34Vpt
   2:     0x7f6270e5a410 - failure::on_fail::h1a2313aec88ac0cbBPz
   3:     0x7f6270dc5470 - rt::unwind::begin_unwind_inner::he6f0b79e492390441tz
   4:     0x7f6270dc8e90 - rt::unwind::begin_unwind_fmt::hdaa836bd1e21d7fcorz
   5:     0x7f6270e5a150 - rust_begin_unwind
   6:     0x7f6270ea1c30 - panicking::panic_fmt::h01dc5ba2c34ad6dcrkl
   7:     0x7f6270e9f930 - panicking::panic::hd3d47337924cd7abRhl
   8:     0x7f6270eabbc0 - str::slice_error_fail::hd4b21ef2840fb40dkTs
   9:     0x7f626f261c20 - util::ppaux::parameterized::h51a43fc8a427293bSfs
  10:     0x7f626f0665d0 - util::ppaux::ty..TraitRef<$u{27}tcx$GT$.UserString$LT$$u{27}tcx$GT$::user_string::h03f731f486ca3ddeOut
  11:     0x7f627032cb30 - util::ppaux::ty..Binder<T>.UserString<$u{27}tcx$GT$::user_string::h6183618980758325180
  12:     0x7f62703280f0 - check::vtable::report_selection_error::h3de6d3cb962c4db3Pib
  13:     0x7f6270327390 - check::vtable::report_fulfillment_errors::hfacd21a10cac75f3Chb
  14:     0x7f6270326a90 - check::vtable::select_all_fcx_obligations_or_error::h52961fddf83aafdeyfb
  15:     0x7f62703f4340 - check::check_bare_fn::h9105b5d7026edf36Ock
  16:     0x7f62703ebe00 - check::check_item::hbc2b32ccaabfff70ewk
  17:     0x7f62706418f0 - check_crate::unboxed_closure.42775
  18:     0x7f627063c750 - check_crate::h77b071454fb3bba7FZy
  19:     0x7f62713884e0 - driver::phase_3_run_analysis_passes::ha627213b53e57939Gta
  20:     0x7f627136b850 - driver::compile_input::heda7e9242e791006tba
  21:     0x7f6271511c30 - run_compiler::h9cf1054d2bef503aCYb
  22:     0x7f62715107d0 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h16457268178976240300
  23:     0x7f627150ee80 - rt::unwind::try::try_fn::h14045550633024131077
  24:     0x7f6270ebe350 - rust_try_inner
  25:     0x7f6270ebe340 - rust_try
  26:     0x7f627150f1b0 - thunk::F.Invoke<A,$u{20}R$GT$::invoke::h17971573902123685032
  27:     0x7f6270e49a50 - sys::thread::thread_start::h915aca80d28489b1tow
  28:     0x7f626b7e8dc0 - start_thread
  29:                0x0 - <unknown>
$ rustc --version
rustc 0.13.0-dev (8443b09e3 2014-12-20 05:52:18 +0000)

Incidentally, it should be clarified that A in Fn<A, R> is actually a meta variable for documentation and Rust only allows a concrete tuple of types there (otherwise we might end up with a closure object which no one can invoke.)

FYI: Dec 15 snapshot didn't suffer from this bug:

$ rustc unboxed-closure-arg-type-tuple.rs 
unboxed-closure-arg-type-tuple.rs:5:5: 5:6 error: the trait `core::ops::Fn<_, _>` is not implemented for the type `||`
unboxed-closure-arg-type-tuple.rs:5     f(|| ())
                                        ^
unboxed-closure-arg-type-tuple.rs:5:5: 5:6 note: required by `f`
unboxed-closure-arg-type-tuple.rs:5     f(|| ())
                                        ^
error: aborting due to previous error

$ rustc --version
rustc 0.13.0-dev (1b97cd338 2014-12-15 15:33:11 +0000)

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