Skip to content

Commit 9042e1e

Browse files
committed
Include static methods on traits in reexports.
1 parent ad8e236 commit 9042e1e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/librustc/metadata/encoder.rs

+42
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 => {

0 commit comments

Comments
 (0)