rust-lang / rust

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

Internal Compiler Error: assertion failed: did.krate != ast::LOCAL_CRATE #22318

Closed GrahamDennis closed 9 years ago

GrahamDennis commented 9 years ago

Rust version:

rustc 1.0.0-nightly (3ef8ff1f8 2015-02-12 00:38:24 +0000)
binary: rustc
commit-hash: 3ef8ff1f81107b42840a695725e1a0869c163355
commit-date: 2015-02-12 00:38:24 +0000
host: x86_64-apple-darwin
release: 1.0.0-nightly

Error:

➜ rust-crdt git:(master) ✗ env RUST_BACKTRACE=1 cargo  build --verbose
   Compiling rust-crdt v0.0.1 (file:///Users/graham/Developer/rust-crdt)
     Running `rustc src/lib.rs --crate-name rust-crdt --crate-type lib -g -C metadata=8dcd9444cd87d8ff -C extra-filename=-8dcd9444cd87d8ff --out-dir /Users/graham/Developer/rust-crdt/target --emit=dep-info,link -L dependency=/Users/graham/Developer/rust-crdt/target -L dependency=/Users/graham/Developer/rust-crdt/target/deps`
error: internal compiler error: unexpected panic
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 'assertion failed: did.krate != ast::LOCAL_CRATE', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc/middle/ty.rs:5383

stack backtrace:
   1:        0x10f2f30a7 - sys::backtrace::write::h1864de2e29cfcfa3jWA
   2:        0x10f31aa02 - failure::on_fail::hb779450ca026c246YwJ
   3:        0x10f265708 - rt::unwind::begin_unwind_inner::h252a44c757d4dd84eeJ
   4:        0x10c0f1555 - rt::unwind::begin_unwind::h9848272882995846808
   5:        0x10c454881 - middle::ty::lookup_trait_def::h8e358ea41ffb8ee8kv9
   6:        0x10c49c2f7 - middle::ty::predicates_for_trait_ref::hac77857a3eb8aa54qw9
   7:        0x10c473a74 - middle::traits::util::Elaborator<'cx, 'tcx>.Iterator::next::h6c40d87b882069f31DU
   8:        0x10c478e71 - middle::traits::util::Supertraits<'cx, 'tcx>.Iterator::next::h992e5ba45c909e1bCGU
   9:        0x10bdab44d - astconv::ast_ty_to_ty::closure.34168
  10:        0x10bd49efd - astconv::ast_ty_to_ty::hfc281cfabc6cd159VHv
  11:        0x10bda1ed8 - vec::Vec<T>.FromIterator<T>::from_iter::h5118803716913674361
  12:        0x10bd9ff1b - astconv::convert_angle_bracketed_parameters::hec3579c8a4af0b23sPu
  13:        0x10bda3c84 - astconv::ast_path_to_trait_ref::h6fdf175b9a3f0841w2u
  14:        0x10bd5509b - astconv::instantiate_trait_ref::ha8d70047126381c3dZu
  15:        0x10bda30ca - astconv::instantiate_poly_trait_ref::he6516e6713c959acCXu
  16:        0x10bdd2b89 - collect::compute_bounds::h41181afabd0333f8b9x
  17:        0x10bdbab0a - collect::trait_def_of_item::h4ebf2ffacbbee292Esx
  18:        0x10bdb918f - collect::CollectTraitDefVisitor<'a, 'tcx>.visit..Visitor<'v>::visit_item::h983a5bf4695c0168PCw
  19:        0x10bdf860f - check_crate::closure.35183
  20:        0x10bdf6625 - check_crate::h6350381f56a0ec2akrB
  21:        0x10b79a2f5 - driver::phase_3_run_analysis_passes::h875436d46bd4a86dSGa
  22:        0x10b780261 - driver::compile_input::h95c8a48d55aa4f35Eba
  23:        0x10b8530a0 - run_compiler::h94216d35105add495bc
  24:        0x10b850572 - thunk::F.Invoke<A, R>::invoke::h12503301436629523007
  25:        0x10b84f240 - rt::unwind::try::try_fn::h15374797505029523364
  26:        0x10f3921a9 - rust_try_inner
  27:        0x10f392196 - rust_try
  28:        0x10b84f939 - thunk::F.Invoke<A, R>::invoke::h5615031943461454492
  29:        0x10f304733 - sys::thread::thread_start::ha3ace5b5b28cf521mOE
  30:     0x7fff93d6f268 - _pthread_body
  31:     0x7fff93d6f1e5 - _pthread_body

Could not compile `rust-crdt`.

Caused by:
  Process didn't exit successfully: `rustc src/lib.rs --crate-name rust-crdt --crate-type lib -g -C metadata=8dcd9444cd87d8ff -C extra-filename=-8dcd9444cd87d8ff --out-dir /Users/graham/Developer/rust-crdt/target --emit=dep-info,link -L dependency=/Users/graham/Developer/rust-crdt/target -L dependency=/Users/graham/Developer/rust-crdt/target/deps` (status=101)

Source code:

use std::sync::Arc;

enum CRDTOperation<T : CRDTSnapshot> {
    Initialise,
    Local(T::Operation, T),
    Merge(T, T),
}

trait CRDTLocalOperation<State> {
    fn apply(&self, state: &State) -> &State;
}

trait CRDTSnapshot {
    type State;
    type Operation : CRDTLocalOperation<Self::State>;

    fn current_state(&self) -> &Self::State;
    fn last_operation(&self) -> &CRDTOperation<Self::Operation>;
}

enum CounterOperation {
    Increment(i64),
}

impl CRDTLocalOperation<i64> for CounterOperation {
    fn apply(&self, state: &i64) -> &i64 {
        match *self {
            CounterOperation::Increment(increment) => increment + state
        }
    }
}

struct CounterSnapshot {
    current_state: i64,
    last_operation: CRDTOperation<CounterSnapshot>
}

impl CounterSnapshot {
    fn new() -> CounterSnapshot {
        CounterSnapshot { current_state: 0, last_operation: CRDTOperation::Initialise }
    }
}

impl CRDTSnapshot for CounterSnapshot {
    type State = i64;
    type Operation = CounterOperation;

    fn current_state(&self) -> &i64 {
        &self.current_state
    }

    fn last_operation(&self) -> &CounterOperation {
        &self.last_operation
    }
}

#[test]
fn it_works() {
    let counter = CounterSnapshot::new();
}
nagisa commented 9 years ago

Duplicate of #21909

Thanks for the report!