Skip to content

ICE when trying cast |:_|{} as _ #19206

@elinorbgr

Description

@elinorbgr

I don't know if this code should be valid or not, but my understanding is that an ICE is always a bug:

#![feature(unboxed_closures)]

use std::sync::Arc;

struct Foo {
    f: Arc<Box<Fn(&u8) + Send + Sync>>,
}

fn main() {
    let foo = Foo {
        f: Arc::new(box |:_|{} as _) 
    }; 
}

↪  rustc --version
rustc 0.13.0-dev (2fcbf90d6 2014-11-21 06:21:48 +0000)

Error:

closure.rs:11:29: 11:36 error: the type of this value must be known in this context
closure.rs:11         f: Arc::new(box |:_|{} as _)
                                          ^~~~~~~
error: internal compiler error: asked to compute contents of error type
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
task 'rustc' panicked at 'Box<Any>', /var/tmp/portage/dev-lang/rust-9999-r3/work/rust-9999/src/libsyntax/diagnostic.rs:180

Sorry but it appears my rustc version (I'm on gentoo) was not compiled with debug symbols, so the backtrace might not be so useful:

stack backtrace:
   1:     0x7f9f5c22e270 - rt::backtrace::imp::write::hbf013c99155ef22dV6s
   2:     0x7f9f5c231b80 - <unknown>
   3:     0x7f9f5be9ac00 - unwind::begin_unwind_inner::hf3353f4eb9dcfd7b4ad
   4:     0x7f9f59cc0850 - <unknown>
   5:     0x7f9f59cc0fc0 - diagnostic::Handler::bug::hee34c9341419bf9246F
   6:     0x7f9f5acbfd30 - session::Session::bug::h2ad38725737e29afXv1
   7:     0x7f9f5ae681d0 - <unknown>
   8:     0x7f9f5ad60170 - middle::ty::type_contents::h369731b5e10654caQT2
   9:     0x7f9f5af548c0 - <unknown>
  10:     0x7f9f5af87b20 - <unknown>
  11:     0x7f9f5af457d0 - <unknown>
  12:     0x7f9f5af21c80 - <unknown>
  13:     0x7f9f5aefe7a0 - <unknown>
  14:     0x7f9f5aefbfc0 - <unknown>
  15:     0x7f9f5af87b20 - <unknown>
  16:     0x7f9f5af87b20 - <unknown>
  17:     0x7f9f5af86330 - <unknown>
  18:     0x7f9f5af87b20 - <unknown>
  19:     0x7f9f5afb6f70 - <unknown>
  20:     0x7f9f5af87b20 - <unknown>
  21:     0x7f9f5afb9460 - middle::typeck::check::check_decl_local::h01cf62672e25b8d3gto
  22:     0x7f9f5afb9620 - middle::typeck::check::check_stmt::h1910b716453576bagvo
  23:     0x7f9f5af457d0 - <unknown>
  24:     0x7f9f5af21c80 - <unknown>
  25:     0x7f9f5af426e0 - <unknown>
  26:     0x7f9f5af3e9c0 - middle::typeck::check::check_item::hd6f8e248c5ec299at9i
  27:     0x7f9f5af423a0 - middle::typeck::check::check_item_types::h8f7b58ccc6ebe03atOi
  28:     0x7f9f5b27ef50 - <unknown>
  29:     0x7f9f5b27e190 - middle::typeck::check_crate::hbb520c43789e920fcwM
  30:     0x7f9f5c79d970 - driver::driver::phase_3_run_analysis_passes::hb8c7de82d0a33d4d7eS
  31:     0x7f9f5c792f10 - driver::driver::compile_input::hcee23d72d4d29b73dWR
  32:     0x7f9f5c81c690 - <unknown>
  33:     0x7f9f5c81c580 - <unknown>
  34:     0x7f9f5c63f2c0 - <unknown>
  35:     0x7f9f5c1b9b90 - <unknown>
  36:     0x7f9f5be98680 - <unknown>
  37:     0x7f9f5bee53f0 - <unknown>
  38:     0x7f9f5bee53e0 - rust_try
  39:     0x7f9f5be98760 - unwind::try::h6cff4bf2d7230683pZc
  40:     0x7f9f5be984f0 - task::Task::run::h8ef72adb50d49429y6b
  41:     0x7f9f5be980e0 - <unknown>
  42:     0x7f9f5be99ed0 - <unknown>
  43:     0x7f9f57464100 - start_thread
  44:     0x7f9f5bb70b89 - clone
  45:                0x0 - <unknown>

I'll update it if I find time to recompile my rustc.

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