提交 6047dd35 编写于 作者: B Brian Anderson

Fix vtable calculations when translating static methods. Closes #4165

上级 0494b078
......@@ -515,15 +515,7 @@ fn combine_impl_and_methods_origins(bcx: block,
let m_boundss = vec::view(*r_m_bounds, n_r_m_tps - n_m_tps, n_r_m_tps);
// Flatten out to find the number of vtables the method expects.
let m_vtables = m_boundss.foldl(0, |sum, m_bounds| {
m_bounds.foldl(*sum, |sum, m_bound| {
(*sum) + match (*m_bound) {
ty::bound_copy | ty::bound_owned |
ty::bound_send | ty::bound_const => 0,
ty::bound_trait(_) => 1
}
})
});
let m_vtables = ty::count_traits_and_supertraits(tcx, m_boundss);
// Find the vtables we computed at type check time and monomorphize them
let r_m_origins = match node_vtables(bcx, callee_id) {
......
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 _: float = Number::from(0.0f);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册