Skip to content

ICE: Using trait object with associated type when associated type is missing #21137

Closed
@ghost

Description

The following code:

trait T {
    type A;
    fn f(&self) -> <Self as T>::A;
}
fn g(t: &T) {
    t.f();
}
fn main() {}

causes an ICE

> rustc bug.rs
bug.rs:5:1: 7:2 warning: function is never used: `g`, #[warn(dead_code)] on by default
bug.rs:5 fn g(t: &T) {
bug.rs:6     t.f();
bug.rs:7 }
error: internal compiler error: fictitious type <T + 'static as T>::A in sizing_type_of()
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 'Box<Any>', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libsyntax\diagnostic.rs:182

stack backtrace:
   1:         0x69bec74b - sys::backtrace::write::hee45dc363cf54780fau
   2:         0x69c011d3 - rt::unwind::register::hf5582984607a5320qZz
   3:         0x69b8369f - rt::unwind::begin_unwind_inner::hdf7945a4fd3670b7YWz
   4:         0x6f895acc - diagnostic::SpanHandler::span_bug::h4d954f56d945afbcxSF
   5:         0x6f896401 - diagnostic::Handler::bug::hfde700047a91c981DYF
   6:           0x889c29 - session::Session::bug::hc8c5fe2087a4f2feg6q
   7:          0x10c2866 - trans::common::u32.AsU64::as_u64::h337407f8534ae8c3Wtl
   8:          0x10e6ce1 - trans::type_::Type...std..cmp..PartialEq::ne::hf0575810ad327032zLJ
   9:          0x10a24ed - trans::expr::Dest...std..cmp..PartialEq::eq::h453cee29cd0986cbuvh
  10:          0x10a080e - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_ast_cleanup_scope::hd8b4f402117b1049sBK
  11:          0x10a1d9d - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::haf6d45af4169747d8LK
  12:          0x116a052 - trans::base::IsUnboxedClosureFlag...std..clone..Clone::clone::h8a85b757d225fec4Q0t
  13:          0x108d722 - trans::context::CrateContext<'b, 'tcx>::sess::h1dbb0dc0ef21a30dFtm
  14:          0x1088c60 - trans::context::CrateContext<'b, 'tcx>::stats::hb6c1f91d25096442BGm
  15:          0x1170248 - trans::base::trans_crate::h5d9a9fb2f49482bcWuv
  16:         0x70b299ca - driver::phase_4_translate_to_llvm::h775a334e971537feYMa
  17:         0x70b02b66 - driver::compile_input::he802c153d1f203eaAba
  18:         0x70bca637 - run::h149ecdcf2d69d1a4M4b
  19:         0x70bc89b8 - run::h149ecdcf2d69d1a4M4b
  20:         0x70bc783a - run::h149ecdcf2d69d1a4M4b
  21:         0x69c2accc - rust_try
  22:         0x69c2aca9 - rust_try
  23:         0x70bc7e6f - run::h149ecdcf2d69d1a4M4b
  24:         0x69bf2032 - sys::tcp::TcpListener::bind::h65fe3155445fa157GKw
  25:         0x76c159ed - BaseThreadInitThunk

in the following version:

rustc 1.0.0-nightly (3d0d9bb6f 2015-01-12 22:56:20 +0000)
binary: rustc
commit-hash: 3d0d9bb6fbdf6ead9396f0874cf38f3ef7c9be5c
commit-date: 2015-01-12 22:56:20 +0000
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)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