Skip to content

Commit 3a1c652

Browse files
committed
---
yaml --- r: 58332 b: refs/heads/auto c: 18a47f9 h: refs/heads/master v: v3
1 parent 93fe285 commit 3a1c652

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: d43d3e538c42798db0706983ba7696b44f6764eb
17+
refs/heads/auto: 18a47f9580c0757f76d6b56081931d10a7859b18
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/librustc/metadata/encoder.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,47 @@ fn encode_path(ecx: @EncodeContext,
363363
ebml_w.end_tag();
364364
}
365365

366+
fn encode_reexported_static_method(ecx: @EncodeContext,
367+
ebml_w: &mut writer::Encoder,
368+
exp: &middle::resolve::Export2,
369+
m: @ty::method) {
370+
debug!("(encode static trait method) reexport '%s::%s'",
371+
*exp.name, *ecx.tcx.sess.str_of(m.ident));
372+
ebml_w.start_tag(tag_items_data_item_reexport);
373+
ebml_w.start_tag(tag_items_data_item_reexport_def_id);
374+
ebml_w.wr_str(def_to_str(m.def_id));
375+
ebml_w.end_tag();
376+
ebml_w.start_tag(tag_items_data_item_reexport_name);
377+
ebml_w.wr_str(*exp.name + "::" + *ecx.tcx.sess.str_of(m.ident));
378+
ebml_w.end_tag();
379+
ebml_w.end_tag();
380+
}
381+
382+
fn encode_reexported_static_methods(ecx: @EncodeContext,
383+
ebml_w: &mut writer::Encoder,
384+
mod_path: &[ast_map::path_elt],
385+
exp: &middle::resolve::Export2) {
386+
match ecx.tcx.trait_methods_cache.find(&exp.def_id) {
387+
Some(methods) => {
388+
match ecx.tcx.items.find(&exp.def_id.node) {
389+
Some(&ast_map::node_item(_, path)) => {
390+
if mod_path != *path {
391+
for methods.each |&m| {
392+
if m.self_ty == ast::sty_static {
393+
encode_reexported_static_method(ecx,
394+
ebml_w,
395+
exp, m);
396+
}
397+
}
398+
}
399+
}
400+
_ => {}
401+
}
402+
}
403+
_ => {}
404+
}
405+
}
406+
366407
fn encode_info_for_mod(ecx: @EncodeContext,
367408
ebml_w: &mut writer::Encoder,
368409
md: &_mod,
@@ -413,6 +454,7 @@ fn encode_info_for_mod(ecx: @EncodeContext,
413454
ebml_w.wr_str(*exp.name);
414455
ebml_w.end_tag();
415456
ebml_w.end_tag();
457+
encode_reexported_static_methods(ecx, ebml_w, path, exp);
416458
}
417459
}
418460
None => {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub use sub_foo::Foo;
12+
13+
pub mod sub_foo {
14+
pub trait Foo {
15+
pub fn foo() -> Self;
16+
}
17+
18+
impl Foo for int {
19+
pub fn foo() -> int { 42 }
20+
}
21+
}
22+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-fast
12+
// aux-build:mod_trait_with_static_methods_lib.rs
13+
extern mod mod_trait_with_static_methods_lib;
14+
15+
use mod_trait_with_static_methods_lib::Foo;
16+
17+
pub fn main() {
18+
assert!(42 == Foo::foo());
19+
}

0 commit comments

Comments
 (0)