Skip to content

ICE when returning trait by-value #18107

Closed
@yuriks

Description

@yuriks

The following code causes an ICE:

pub trait AbstractRenderer {}

fn _create_render(_: &()) -> AbstractRenderer {
    match 0u {
        _ => unimplemented!()
    }
}

fn main() {
}
error: internal compiler error: trying to take the sizing type of AbstractRenderer, an unsized type
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 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:169

stack backtrace:
   1:     0x7ff0cb624510 - rt::backtrace::imp::write::hdbb48f4c53a7cc60gDq
   2:     0x7ff0cb627640 - failure::on_fail::h664e14eeb2ff8c0bDYq
   3:     0x7ff0cbdc68b0 - unwind::begin_unwind_inner::h56f904cfbaefac03Gxd
   4:     0x7ff0c7d23d00 - unwind::begin_unwind::h3274104174448703340
   5:     0x7ff0c7d243e0 - diagnostic::Handler::bug::h1e32cdde49e6b788hRF
   6:     0x7ff0cc597a70 - middle::trans::type_of::sizing_type_of::h84c9c04a390ab352vra
   7:     0x7ff0cc584830 - middle::trans::controlflow::trans_block::h82c14c3960cf3218lGZ
   8:     0x7ff0cc634f60 - middle::trans::base::trans_closure::h1124c66088a31168XBf
   9:     0x7ff0cc576340 - middle::trans::base::trans_fn::h857e35768e8962d1lNf
  10:     0x7ff0cc5739a0 - middle::trans::base::trans_item::h0a9a277363bc9736E6f
  11:     0x7ff0cc640520 - middle::trans::base::trans_crate::hd70672a3161c49aaa5g
  12:     0x7ff0cca918b0 - driver::driver::phase_4_translate_to_llvm::hab1a6d4c1e3d8a4cvFx
  13:     0x7ff0cca87bb0 - driver::driver::compile_input::h6e2a623e71c52de1qcx
  14:     0x7ff0ccb12b00 - driver::run_compiler::h5364c643a9540453J0A
  15:     0x7ff0ccb129b0 - driver::run::closure.147480
  16:     0x7ff0cc1dad50 - task::TaskBuilder<S>::try_future::closure.101591
  17:     0x7ff0cc1dab30 - task::TaskBuilder<S>::spawn_internal::closure.101562
  18:     0x7ff0cd381a30 - task::spawn_opts::closure.8447
  19:     0x7ff0cbe20820 - rust_try_inner
  20:     0x7ff0cbe20810 - rust_try
  21:     0x7ff0cbdc4170 - unwind::try::hc8fa40147cc0bedbomd
  22:     0x7ff0cbdc3ff0 - task::Task::run::h67469f5b91c0b2922Bc
  23:     0x7ff0cd381770 - task::spawn_opts::closure.8387
  24:     0x7ff0cbdc58c0 - thread::thread_start::he00c50880746ce61dWc
  25:     0x7ff0cb0ec250 - start_thread
  26:     0x7ff0cba9e3b9 - clone
  27:                0x0 - <unknown>

Removing the parameter or changing it to be a value instead of a reference stops the crash with an error saying I need to specify a lifetime, which makes me think this is a problem related to inferred lifetimes.

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