diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index b5c7e1f6195a66bfa751f5df73fd0ff49310c729..d214208560419b94b005979dda23080a5ff186af 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -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) { diff --git a/src/test/run-pass/static-methods-in-traits2.rs b/src/test/run-pass/static-methods-in-traits2.rs new file mode 100644 index 0000000000000000000000000000000000000000..1545c98156dedd33b66047fa6b67f95bc4ee8264 --- /dev/null +++ b/src/test/run-pass/static-methods-in-traits2.rs @@ -0,0 +1,19 @@ +pub trait Number: NumConv { + static pure fn from(n: T) -> self; +} + +pub impl float: Number { + static pure fn from(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