Closed
Description
pub struct Vec2<T> { x: T, y: T }
pub impl<T:Copy Number> Vec2<T> {
static pure fn zero() -> Vec2<T> {
let _0 = Number::from(0f); // FIXME: causes ICE
Vec2 { x: _0, y: _0 }
}
}
pub trait Number: NumConv {
static pure fn from<T:Number>(n: T) -> self;
}
pub impl float: Number {
static pure fn from<T:Number>(n: T) -> float { n.to_float() }
}
pub trait NumConv {
pure fn to_float(&self) -> float;
}
pub impl float: NumConv {
pure fn to_float(&self) -> float { *self }
}
fn main() {
let _: Vec2<float> = Vec2::zero();
}
$ RUST_LOG=rustc=1,::rt::backtrace rustc src/vec.rs
rust: task failed at 'index out of bounds: the len is 1 but the index is 1', /usr/local/src/rust/src/librustc/middle/trans/common.rs:1327
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /usr/local/src/rust/src/librustc/rustc.rc:483
rust: domain main @0x7f8a0c800010 root task failed
rust: task failed at 'killed', /usr/local/src/rust/src/libcore/task/mod.rs:630
Context: