Issue 1:
I have two similar pieces of code that I would expect to behave in a similar fashion. The first piece of code compiles and functions properly:

trait HasId {
fn id() -> i32;
}

trait Foo {}

impl HasId for Foo {
fn id() -> i32 { 1 }
}

trait Bar {}

impl HasId for Bar {
fn id() -> i32 { 2 }
}

fn print_id<T: HasId + ?Sized>() {
println!("{}", <T as HasId>::id());
}

fn main() {
print_id::<Foo>();
print_id::<Bar>();
}

The second piece of code replaces the static methods with an associated constant:

#![feature(associated_consts)]

trait HasId {
const ID: i32;
}

trait Foo {}

impl HasId for Foo {
const ID: i32 = 1;
}

trait Bar {}

impl HasId for Bar {
const ID: i32 = 2;
}

fn print_id<T: HasId + ?Sized>() {
println!("{}", <T as HasId>::ID);
}

fn main() {
print_id::<Foo>();
print_id::<Bar>();
}

This code fails to compile with the following ICE:

<anon>:4:5: 4:19 error: internal compiler error: Encountered error `Unimplemented` when trying to select an implementation for constant trait item reference.
<anon>:4 const ID: i32;
^~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:170

What's interesting is that the following code does compile:

#![feature(associated_consts)]

trait HasId {
const ID: i32;
}

trait Foo {}

impl HasId for Foo {
const ID: i32 = 1;
}

trait Bar {}

impl HasId for Bar {
const ID: i32 = 2;
}

fn main() {
println!("{}", <Foo as HasId>::ID);
println!("{}", <Bar as HasId>::ID);
}

So it would appear as if this behavior is related to the use of a generic in the UFCS resolution for the associated constant.

Issue 2:
The compiler fails to compile this:

#![feature(associated_consts)]

pub trait Foo {
const MIN: i32;

fn get_min() -> i32 {
Self::MIN
}
}

fn main() {}

The error message:

main.rs:4:5: 4:20 error: internal compiler error: Encountered error `Unimplemented` when trying to select an implementation for constant trait item reference.
main.rs:4 const MIN: i32;
^~~~~~~~~~~~~~~
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:170

Meta

rustc --version --verbose:

rustc 1.1.0-nightly (c4b23ae 2015-04-29) (built 2015-04-28)

binary: rustc

commit-hash: c4b23ae

commit-date: 2015-04-29

build-date: 2015-04-28

host: x86_64-apple-darwin

release: 1.1.0-nightly

Stack backtrace:

1: 0x10ae5424f - sys::backtrace::write::h0714aaf7fe41e02dzVr
2: 0x10ae5c8c0 - panicking::on_panic::hb86b9b356f51f92dEVv
3: 0x10ae18c35 - rt::unwind::begin_unwind_inner::h58f79e41dbedf2efnDv
4: 0x10a60998e - rt::unwind::begin_unwind::h17476740655312162035
5: 0x10a60991a - diagnostic::SpanHandler::span_bug::h6ece18e7aebef0b3cFB
6: 0x108027cfa - middle::const_eval::resolve_trait_associated_const::hfcf715732ac1e584QMi
7: 0x107fdba61 - middle::const_eval::lookup_const_by_id::hc5a8309a206ad882OOg
8: 0x107fd58b2 - middle::check_const::check_expr::h4c113c7ea3d8c1ffB2d
9: 0x107fcd77c - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_expr::hdb217d3565a2586cGTd
10: 0x107fd3e7e - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_fn::h37b9b5487c182e36DRd
11: 0x107fd454e - visit::walk_trait_item::h8343690369834256746
12: 0x107fd349f - visit::walk_item::h4252660852014709521
13: 0x107fd2e1c - middle::check_const::CheckCrateVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h3645f3202d46494bKMd
14: 0x107fdbeea - middle::check_const::check_crate::ha1c34da7b8765db0Hle
15: 0x107584171 - driver::phase_3_run_analysis_passes::h2554ff95bce00587tGa
16: 0x10756618c - driver::compile_input::h7c6cf9b085c57594Qba
17: 0x107625ac3 - run_compiler::h55b523753cbd518765b
18: 0x10762322a - boxed::F.FnBox<A>::call_box::h11476165885616507686
19: 0x107622767 - rt::unwind::try::try_fn::h13518150216340287792
20: 0x10aedec58 - rust_try_inner
21: 0x10aedec45 - rust_try
22: 0x107622a4e - boxed::F.FnBox<A>::call_box::h735039165869315632
23: 0x10ae5b2bd - sys::thread::Thread::new::thread_start::hf4c42a114072ab47mYu
24: 0x7fff8cfab267 - _pthread_body
25: 0x7fff8cfab1e4 - _pthread_start