Issue 1:
I'm fleshing out the json library to add support for a to_json iface, among other things, and I'm finding a lot of code duplication between my instances. Here's an example:

iface to_json {
fn to_json_writer(wr: io::writer);
fn to_json_str() -> str;
}

impl of to_json for float {
fn to_json_writer(wr: io::writer) {
wr.write_str(float::to_str(self, 6u));
}

fn to_json_str() -> str {
io::with_str_writer(self.to_json_writer)
}
}

impl of to_json for int {
fn to_json_writer(wr: io::writer) {
wr.write_str(int::str(self));
}

fn to_json_str() -> str {
io::with_str_writer(self.to_json_writer)
}
}
...

Every implementation's to_json_str is just a straight copy of the others. It would be much nicer if we could provide default versions of functions like to_json_str and just have the implementations inherit it.

iface to_json {
fn to_json_writer(wr: io::writer);
fn to_json_str() -> str {
io::with_str_writer(self.to_json_writer)
}
}

Issue 2:
Hi folks,

I think my code is wrong, but since it says this is a compiler bug I thought I'd file it.

I'm on rustc 0.11.0-pre-nightly (bb5695b95c288c442dbe528f7e1c1b08f79f033d 2014-06-29 23:36:43 +0000) (os x)

I have the following code:

extern crate crypto = "rust-crypto";

use std::io::stdio::println;
use crypto::md5::Md5;
use crypto::digest::Digest;

fn main() {
println!("{}", ketama("Hello World!"));
}

fn ketama(key: &str) -> u8 {

// 2: Create MD5 digset
let mut sh = Md5::new();
sh.input_str(key);
let mut digest = Vec::from_elem((sh.output_bits()+7)/8, 0u8);
sh.result(digest.as_mut_slice());

// 3: Construct the ketama hash
let result =
((digest.get(3) & 0xFF) << 24) |
((digest.get(2) & 0xFF) << 16) |
((digest.get(1) & 0xFF) << 8) |
(digest.get(0) & 0xFF);

result
}

#[cfg(test)]
mod tests {

use ketama;

fn test_ketama() {
assert!(3979113294, ketama("26"));
}

}

and the error popped up as I added the use ketama to the tests module.

When I run cargo test on my file I get:

┌─[✗]─[michael@daschlbase]─[~/code/rust/ketama]
└──╼ RUST_BACKTRACE=1 cargo test
Fresh rust-crypto v0.1.0 (https://github.com/DaGenix/rust-crypto.git)
Compiling ketama-rs v0.1.0 (file:/Users/michaelnitschinger/code/rust/ketama)
<std macros>:8:12: 35:21 error: mismatched types: expected `bool` but found `<generic integer #0>` (expected bool but found integral variable)
<std macros>:8 if !$cond {
<std macros>:9 fail!($($arg),+)
<std macros>:10 }
<std macros>:11 );
<std macros>:12 )
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'index out of bounds: the len is 12 but the index is 12', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/lib.rs:1

stack backtrace:
1: 0x1054f0655 - rt::backtrace::imp::write::h33d600b14bcc0ad7tPp::v0.11.0.pre
2: 0x1054f6bf7 - failure::on_fail::h8275f76a6db57202M5p::v0.11.0.pre
3: 0x1057a7e09 - unwind::begin_unwind_inner::hd390bdc7271bbf4cIVd::v0.11.0.pre
4: 0x1057a78bd - unwind::begin_unwind_fmt::hfa8fc7b11f5dad16bTd::v0.11.0.pre
5: 0x1057a7711 - rust_begin_unwind
6: 0x1057f3bbe - failure::begin_unwind::h29121687d16d4062X2v::v0.11.0.pre
7: 0x1057f8189 - failure::fail_bounds_check::hb0b1b63e7b73cbf690v::v0.11.0.pre
8: 0x104c7715d - codemap::FileMap::get_line::hf69850111b874f5dRDd::v0.11.0.pre
9: 0x104c73656 - diagnostic::emit::hc4f6ec047e6b64740uc::v0.11.0.pre
10: 0x104c6e652 - diagnostic::EmitterWriter.Emitter::emit::h892977fb7f421d339qc::v0.11.0.pre
11: 0x104c6c953 - diagnostic::Handler::emit::h755ef325bde394dakec::v0.11.0.pre
12: 0x104c6b975 - diagnostic::SpanHandler::span_err::h266f98379c75b6f9Q4b::v0.11.0.pre
13: 0x102669cb6 - middle::typeck::infer::InferCtxt<'a>::type_error_message_str_with_expected::h506fef97717d30f26Kw::v0.11.0.pre
14: 0x102714993 - middle::typeck::infer::InferCtxt<'a>::type_error_message::h4ac10c0197867eadOSw::v0.11.0.pre
15: 0x102714ad9 - middle::typeck::infer::InferCtxt<'a>::report_mismatched_types::h09f90236d1ff10f5TTw::v0.11.0.pre
16: 0x1026cf748 - middle::typeck::check::demand::suptype::closure.91708
17: 0x1026cf680 - middle::typeck::check::demand::suptype_with_fn::h5aef443dd5c41e99dga::v0.11.0.pre
18: 0x10271eec8 - middle::typeck::check::check_expr_has_type::closure.92600
19: 0x102718eec - middle::typeck::check::check_expr_with_unifier::h7a4a57fad133af797rf::v0.11.0.pre
20: 0x1027198ef - middle::typeck::check::check_expr_with_unifier::h7a4a57fad133af797rf::v0.11.0.pre
21: 0x102733001 - middle::typeck::check::check_stmt::h2a033ee04cabfc221ih::v0.11.0.pre
22: 0x1026ef142 - middle::typeck::check::check_block_with_expected::h020999ba5c44c098cnh::v0.11.0.pre
23: 0x1026ead0d - middle::typeck::check::check_fn::h6413530500ad7359jUc::v0.11.0.pre
24: 0x1026ea6e0 - middle::typeck::check::check_bare_fn::h42022f9acab71088RJc::v0.11.0.pre
25: 0x1026e43ee - middle::typeck::check::check_item::h06e560567b39b12e5gd::v0.11.0.pre
26: 0x1026e5d3d - visit::walk_item::h12564307020263923332::v0.11.0.pre
27: 0x1026ea4c0 - middle::typeck::check::check_item_types::h8b297d641b758de99Ic::v0.11.0.pre
28: 0x10285c24e - middle::typeck::check_crate::h901cb82af492c67cSJC::v0.11.0.pre
29: 0x102cb0dc8 - driver::driver::phase_3_run_analysis_passes::h5dd5f16878eed1ed84p::v0.11.0.pre
30: 0x102cabe15 - driver::driver::compile_input::h85050a3ac86049856Rp::v0.11.0.pre
31: 0x102d7256b - driver::run_compiler::hae8f05bffa41c7b05Bs::v0.11.0.pre
32: 0x102d6fd86 - driver::main_args::closure.117272
33: 0x102d8445b - task::TaskBuilder<S>::try_future::closure.118413
34: 0x102d842f4 - task::TaskBuilder<S>::spawn_internal::closure.118390
35: 0x104be895c - task::spawn_opts::closure.7562
36: 0x10580d0ac - rust_try
37: 0x1057a42aa - unwind::try::h803831d3cb7669807Jd::v0.11.0.pre
38: 0x1057a3fac - task::Task::run::h4a0e5408354628dfZVc::v0.11.0.pre
39: 0x104be87eb - task::spawn_opts::closure.7507
40: 0x1057a6b19 - thread::thread_start::h5aa600706e7c5c88xid::v0.11.0.pre
41: 0x7fff92c10899 - _pthread_body
42: 0x7fff92c1072a - _pthread_struct_init

feel free to close if its not an issue.

Cheers,

Michael