Skip to content

ICE on missing Target type in Deref implementation #20480

Closed
@swatteau

Description

@swatteau

Version of Rust: rustc 0.13.0-nightly (c894171 2015-01-02 21:56:13 +0000)
Operating system: Linux 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt2-1 (2014-12-08) i686 GNU/Linux

When the associated Target type is not defined in an impl Deref, this leads to an internal compiler error.

Here is an example:

#![feature(associated_types)]
use std::ops::Deref;

struct Wrapper {
    inner: int
}

impl Deref for Wrapper {
    //type Target = int;
    fn deref(&self) -> &int {
        &self.inner
    }
}

fn main() {
}

Error message from the compiler:

src/main.rs:10:5: 12:6 error: internal compiler error: impl `VtableImpl(impl_def_id=DefId { krate: 0, node: 10 }:Wrapper.Deref, substs=Substs[types=[[];[];[]], regions=[[];[];[]]], nested=[[];[];[]])` did not contain projection for `Obligation(predicate=<Wrapper as TraitRef(Wrapper, core::ops::Deref)>::Target,depth=0)`
src/main.rs:10     fn deref(&self) -> &int {
src/main.rs:11         &self.inner
src/main.rs:12     }
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

Backtrace:

thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1: 0xb7383f20 - sys::backtrace::write::h6d0a4417f4e5c493sit
   2: 0xb73a8770 - failure::on_fail::h17e5357971ef1fadTuz
   3: 0xb7310d00 - rt::unwind::begin_unwind_inner::h81966bf04c2cd1f4y9y
   4: 0xb389edb0 - rt::unwind::begin_unwind::h12436254939101185090
   5: 0xb389ed20 - diagnostic::SpanHandler::span_bug::h64fa6f5fbd27e941zFF
   6: 0xb6326a10 - middle::traits::project::project_type::h85510b9af23c51a6UQP
   7: 0xb6323b00 - middle::traits::project::opt_normalize_projection_type::h16b6e65a2aa8a5c1XIP
   8: 0xb6312320 - middle::traits::project::normalize_projection_type::h4e3c940bec71651byHP
   9: 0xb6324ea0 - middle::traits::project::AssociatedTypeNormalizer<'a, 'b, 'tcx>.TypeFolder<'tcx>::fold_ty::h3cbce0725be04edf9FP
  10: 0xb6324ea0 - middle::traits::project::AssociatedTypeNormalizer<'a, 'b, 'tcx>.TypeFolder<'tcx>::fold_ty::h3cbce0725be04edf9FP
  11: 0xb6dc4600 - middle::ty_fold::ty..FnSig<'tcx>.TypeFoldable<'tcx>::fold_with::h10991263838617593069
  12: 0xb6e58690 - check::assoc::normalize_associated_types_in::h9980513805539501870
  13: 0xb6e4eae0 - check::compare_impl_method::h37df9bd14bbfe837q4j
  14: 0xb6e3aed0 - check::check_item::hda7b1175944bf853SGj
  15: 0xb6ff1830 - check_crate::unboxed_closure.39847
  16: 0xb6fec070 - check_crate::h5a3950962091692dVlx
  17: 0xb76bf8b0 - driver::phase_3_run_analysis_passes::hf1b11de46876f77cTva
  18: 0xb76ad980 - driver::compile_input::h567277daca5fdd24wba
  19: 0xb777fa80 - thunk::F.Invoke<A, R>::invoke::h14467627679629470429
  20: 0xb777e890 - rt::unwind::try::try_fn::h7264457252665277252
  21: 0xb7418c90 - rust_try_inner
  22: 0xb7418c60 - rust_try
  23: 0xb777ebd0 - thunk::F.Invoke<A, R>::invoke::h428659666485879903
  24: 0xb73956c0 - sys::thread::thread_start::haeae5d792ecbddcdy8v
  25: 0xb36c4e30 - start_thread
  26: 0xb71eddf2 - clone
  27:        0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions