提交 e02716e6 编写于 作者: T Tom Lee

Reexport static trait methods on traits in the same module.

上级 ebdb0dee
......@@ -386,8 +386,10 @@ fn encode_reexported_static_methods(ecx: @EncodeContext,
match ecx.tcx.trait_methods_cache.find(&exp.def_id) {
Some(methods) => {
match ecx.tcx.items.find(&exp.def_id.node) {
Some(&ast_map::node_item(_, path)) => {
if mod_path != *path {
Some(&ast_map::node_item(item, path)) => {
let interner = ecx.tcx.sess.parse_sess.interner;
let original_name = ecx.tcx.sess.str_of(item.ident);
if mod_path != *path || *exp.name != *original_name {
for methods.each |&m| {
if m.explicit_self == ast::sty_static {
encode_reexported_static_method(ecx,
......
......@@ -9,6 +9,15 @@
// except according to those terms.
pub use sub_foo::Foo;
pub use Baz = self::Bar;
pub trait Bar {
pub fn bar() -> Self;
}
impl Bar for int {
pub fn bar() -> int { 84 }
}
pub mod sub_foo {
pub trait Foo {
......@@ -18,4 +27,5 @@ pub trait Foo {
impl Foo for int {
pub fn foo() -> int { 42 }
}
}
......@@ -13,7 +13,9 @@
extern mod mod_trait_with_static_methods_lib;
use mod_trait_with_static_methods_lib::Foo;
use mod_trait_with_static_methods_lib::Baz;
pub fn main() {
assert_eq!(42, Foo::foo());
assert_eq!(84, Baz::bar());
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册