rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.08k stars 12.79k forks source link

Internal compiler error when using operator overloading #20758

Closed jethrogb closed 9 years ago

jethrogb commented 9 years ago
use std::ops::BitAnd;

struct A;

impl BitAnd for A
{
    pub fn bitand(self, other: A) -> A
    {
        return self;
    }
}
$rustc --version --verbose
rustc 0.13.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 0.13.0-dev
$RUST_BACKTRACE=1 rustc --crate-type=rlib min.rs 
min.rs:5:1: 11:2 error: internal compiler error: impl `VtableImpl(impl_def_id=DefId { krate: 0, node: 8 }:A.BitAnd, substs=Substs[types=[[];[];[]], regions=[[];[];[]]], nested=[[];[];[]])` did not contain projection for `Obligation(predicate=<A as TraitRef(A, core::ops::BitAnd)>::Output,depth=0)`
min.rs:5 impl BitAnd for A
min.rs:6 {
min.rs:7    pub fn bitand(self, other: A) -> A
min.rs:8    {
min.rs:9        return self;
min.rs:10   }
          ...
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>', /build/buildd/rust-nightly-201501060408~c7dd3c4~trusty/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:     0x7f5b4da2e160 - sys::backtrace::write::h2869e999018bc7f0CQs
   2:     0x7f5b4da53eb0 - <unknown>
   3:     0x7f5b4d9b9ce0 - rt::unwind::begin_unwind_inner::h8b739acb3b55fd19VHy
   4:     0x7f5b48a69450 - <unknown>
   5:     0x7f5b48a693e0 - diagnostic::SpanHandler::span_bug::h4784e9b3e2a7ed570kF
   6:     0x7f5b4be5f110 - <unknown>
   7:     0x7f5b4be5c500 - <unknown>
   8:     0x7f5b4be49fc0 - <unknown>
   9:     0x7f5b4be5d9a0 - middle::traits::project::AssociatedTypeNormalizer<'a, 'b, 'tcx>.TypeFolder<'tcx>::fold_ty::hfd8fd83cad853555OFP
  10:     0x7f5b4d156b70 - <unknown>
  11:     0x7f5b4d1577a0 - <unknown>
  12:     0x7f5b4d1731c0 - <unknown>
  13:     0x7f5b4d18a970 - <unknown>
  14:     0x7f5b4d18db40 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::hf7248b70b9c6b449tki
  15:     0x7f5b4d29ada0 - <unknown>
  16:     0x7f5b4d2959e0 - check_crate::h8fa7902ab9b76426amx
  17:     0x7f5b4df6d260 - driver::phase_3_run_analysis_passes::h85052bc04c895a90Sva
  18:     0x7f5b4df5b790 - driver::compile_input::hc42de447758318b2vba
  19:     0x7f5b4e022580 - <unknown>
  20:     0x7f5b4e021330 - <unknown>
  21:     0x7f5b4dab76b0 - <unknown>
  22:     0x7f5b4dab76a0 - rust_try
  23:     0x7f5b4e021680 - <unknown>
  24:     0x7f5b4da3fce0 - <unknown>
  25:     0x7f5b4828c0c0 - start_thread
  26:     0x7f5b4d662ec9 - __clone
  27:                0x0 - <unknown>

Not sure why the version is not coming up correctly, I'm using rust-nightly 201501060408~c7dd3c4~trusty from the PPA.

jdm commented 9 years ago

This might be a dup of #20347. Try a more recent nightly?

jethrogb commented 9 years ago

Fixed in 201501080408~9f1ead8~trusty.