Issue 1:
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();
}

Issue 2:
The code below triggers an internal compiler error:

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:5341

Smallest input file that tickles the error:

trait A<X> { }
trait B { type X; type Y : A<Self::X>; }
fn main () { }

When the bounds on Y are lifted, the bug goes away for me. That is, the following code compiles without an error:

trait A<X> { }
trait B { type X; type Y; }
fn main () { }

Version info:

rustc 1.0.0-nightly (f1398d273 2015-01-31 20:21:02 +0000)
binary: rustc
commit-hash: f1398d2736f132dd4af828b3d9134691f924b7e1
commit-date: 2015-01-31 20:21:02 +0000
host: x86_64-apple-darwin
release: 1.0.0-nightly

Backtrace:

stack backtrace:
1: 0x10d966b27 - sys::backtrace::write::h1e2c8d6454da8cd1Xsu
2: 0x10d98ccac - failure::on_fail::hc34cc2536b843a6dlwB
3: 0x10d8ed878 - rt::unwind::begin_unwind_inner::hc1db7917310b1e46PdB
4: 0x10a931c55 - rt::unwind::begin_unwind::h10851544081918456271
5: 0x10ac96d80 - middle::ty::lookup_trait_def::h2256fffe21aabd99WH7
6: 0x10acdbc17 - middle::ty::predicates_for_trait_ref::h5f31438d5452493c2I7
7: 0x10acb3dcb - middle::traits::util::Elaborator<'cx, 'tcx>.Iterator::next::h8fa8483eadd3bbe7IgT
8: 0x10acb9d94 - middle::traits::util::Supertraits<'cx, 'tcx>.Iterator::next::h55572798b69df69ajjT
9: 0x10a5face7 - astconv::ast_ty_to_ty::closure.32964
10: 0x10a594dc0 - astconv::ast_ty_to_ty::h28c37a0bcd64f3d22ru
11: 0x10a5f0eed - vec::Vec<T>.FromIterator<T>::from_iter::h8194170135992664305
12: 0x10a5ee9fe - astconv::convert_angle_bracketed_parameters::h14e1151854724c322zt
13: 0x10a5f2d2b - astconv::ast_path_to_trait_ref::h8901deac3602014bVMt
14: 0x10a5a081b - astconv::instantiate_trait_ref::haaed26dc31d8d3a8CJt
15: 0x10a5f20ea - astconv::instantiate_poly_trait_ref::h5e153a7725bdcb786Ht
16: 0x10a622fcb - collect::compute_bounds::hbff2a6aea3e3160byRw
17: 0x10a60a5fd - collect::trait_def_of_item::hc2a893dcfe8940b96bw
18: 0x10a608bdf - collect::CollectTraitDefVisitor<'a, 'tcx>.visit..Visitor<'v>::visit_item::haff1fcbfc2eb31abLmv
19: 0x10a648c6f - check_crate::closure.34094
20: 0x10a646c75 - check_crate::he1eddd9d21d7c627g8z
21: 0x109ff6725 - driver::phase_3_run_analysis_passes::h5ea5b4fae09df7e4tGa
22: 0x109fdcb9c - driver::compile_input::hfeebf01fd34be13bBba
23: 0x10a0aa27e - run_compiler::h47834abf04acfba99ac
24: 0x10a0a729f - thunk::F.Invoke<A, R>::invoke::h2084430363117493962
25: 0x10a0a5f30 - rt::unwind::try::try_fn::h12547055720005252601
26: 0x10da03b69 - rust_try_inner
27: 0x10da03b56 - rust_try
28: 0x10a0a65f4 - thunk::F.Invoke<A, R>::invoke::h838828363178605749
29: 0x10d977333 - sys::thread::thread_start::h502153f3460908456lx
30: 0x7fff951c02fc - _pthread_body
31: 0x7fff951c0279 - _pthread_body