Skip to content

ICE: Trait in an Rc #24984

Closed
Closed
@vojtechkral

Description

@vojtechkral

Code:

use std::rc::Rc;

struct Foo;

trait Bar {}

impl Foo
{
    fn new(_: Rc<Bar>) {}
}

fn main() {}

Backtrace:

$ RUST_BACKTRACE=1 rustc ice.rs
ice.rs:3:1: 3:12 warning: struct is never used: `Foo`, #[warn(dead_code)] on by default
ice.rs:3 struct Foo;
         ^~~~~~~~~~~
ice.rs:9:2: 9:23 warning: method is never used: `new`, #[warn(dead_code)] on by default
ice.rs:9        fn new(_: Rc<Bar>) {}
                ^~~~~~~~~~~~~~~~~~~~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Unexpected type returned from struct_tail: usize for ty=alloc::rc::RcBox<Bar>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/trans/type_of.rs:366

stack backtrace:
   1:     0x7f57e2b50429 - sys::backtrace::write::h0310b8a8758e1499qYr
   2:     0x7f57e2b58199 - panicking::on_panic::hbad58b50e2163063low
   3:     0x7f57e2b19e72 - rt::unwind::begin_unwind_inner::h64a2ef53e7d2411bv3v
   4:     0x7f57e2b1ac37 - rt::unwind::begin_unwind_fmt::h9c5772ad7a47f90bB2v
   5:     0x7f57e1917dae - trans::type_of::in_memory_type_of::h188c1c7c41bc9d7f7tL
   6:     0x7f57e19172bb - vec::Vec<T>.FromIterator<T>::from_iter::h14269379071952906095
   7:     0x7f57e1917ed0 - trans::type_of::in_memory_type_of::h188c1c7c41bc9d7f7tL
   8:     0x7f57e19172bb - vec::Vec<T>.FromIterator<T>::from_iter::h14269379071952906095
   9:     0x7f57e1917ed0 - trans::type_of::in_memory_type_of::h188c1c7c41bc9d7f7tL
  10:     0x7f57e19e4e64 - trans::type_of::type_of_rust_fn::hfb2f3fddb3e82849QhL
  11:     0x7f57e1924c0e - trans::declare::declare_rust_fn::h9bf6d0da36152a67VLz
  12:     0x7f57e194a7f7 - trans::base::register_fn::he474a7f56ecf391fSpi
  13:     0x7f57e194daa8 - trans::base::register_method::h957a1d7bf5a0608eCSi
  14:     0x7f57e19456a5 - trans::base::get_item_val::hc16030242241a466ACi
  15:     0x7f57e1942771 - trans::base::trans_item::h3179c4631dcee2ebCei
  16:     0x7f57e194fd44 - trans::base::trans_crate::hade7d63770de815bp3i
  17:     0x7f57e309c73a - driver::phase_4_translate_to_llvm::h00417005a319753enOa
  18:     0x7f57e3074c86 - driver::compile_input::hfaa649c14fe92e11Qba
  19:     0x7f57e312deb1 - run_compiler::h975f4126834a7e6a65b
  20:     0x7f57e312b702 - boxed::F.FnBox<A>::call_box::h13703319857629066322
  21:     0x7f57e312aca9 - rt::unwind::try::try_fn::h2284512932531354838
  22:     0x7f57e2bcba58 - rust_try_inner
  23:     0x7f57e2bcba45 - rust_try
  24:     0x7f57e312af50 - boxed::F.FnBox<A>::call_box::h8871555247671848559
  25:     0x7f57e2b56f31 - sys::thread::Thread::new::thread_start::h051fcff982868631R9u
  26:     0x7f57dcc05373 - start_thread
  27:     0x7f57e27ae27c - clone
  28:                0x0 - <unknown>

Platform:

$ rustc --version --verbose
rustc 1.1.0-nightly (c4b23aec4 2015-04-29) (built 2015-04-29)
binary: rustc
commit-hash: c4b23aec4c5ddf32df1e0ba3cc23212327cd8b1f
commit-date: 2015-04-29
build-date: 2015-04-29
host: x86_64-unknown-linux-gnu
release: 1.1.0-nightly

Note that using Arc instead of Rc generates an ICE too.
Hope this is not a dupe - it's kind of hard to tell which ICE is equivalent...

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