Skip to content

Commit 6bfdf37

Browse files
committed
remove code for re-exports of static methods
1 parent 52a0283 commit 6bfdf37

File tree

1 file changed

+3
-119
lines changed

1 file changed

+3
-119
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -366,120 +366,6 @@ fn encode_path<PI: Iterator<Item=PathElem>>(rbml_w: &mut Encoder, path: PI) {
366366
rbml_w.end_tag();
367367
}
368368

369-
fn encode_reexported_static_method(rbml_w: &mut Encoder,
370-
exp: &def::Export,
371-
method_def_id: DefId,
372-
method_name: Name) {
373-
debug!("(encode reexported static method) {}::{}",
374-
exp.name, method_name);
375-
rbml_w.start_tag(tag_items_data_item_reexport);
376-
rbml_w.wr_tagged_u64(tag_items_data_item_reexport_def_id,
377-
def_to_u64(method_def_id));
378-
rbml_w.wr_tagged_str(tag_items_data_item_reexport_name,
379-
&format!("{}::{}", exp.name,
380-
method_name));
381-
rbml_w.end_tag();
382-
}
383-
384-
fn encode_reexported_static_base_methods(ecx: &EncodeContext,
385-
rbml_w: &mut Encoder,
386-
exp: &def::Export)
387-
-> bool {
388-
let impl_items = ecx.tcx.impl_items.borrow();
389-
match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
390-
Some(implementations) => {
391-
for base_impl_did in implementations.iter() {
392-
for &method_did in impl_items.get(base_impl_did).unwrap() {
393-
let impl_item = ecx.tcx.impl_or_trait_item(method_did.def_id());
394-
if let ty::MethodTraitItem(ref m) = impl_item {
395-
encode_reexported_static_method(rbml_w,
396-
exp,
397-
m.def_id,
398-
m.name);
399-
}
400-
}
401-
}
402-
403-
true
404-
}
405-
None => { false }
406-
}
407-
}
408-
409-
fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
410-
rbml_w: &mut Encoder,
411-
exp: &def::Export)
412-
-> bool {
413-
match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
414-
Some(trait_items) => {
415-
for trait_item in trait_items.iter() {
416-
if let ty::MethodTraitItem(ref m) = *trait_item {
417-
encode_reexported_static_method(rbml_w,
418-
exp,
419-
m.def_id,
420-
m.name);
421-
}
422-
}
423-
true
424-
}
425-
None => { false }
426-
}
427-
}
428-
429-
fn encode_reexported_static_methods(ecx: &EncodeContext,
430-
rbml_w: &mut Encoder,
431-
mod_path: PathElems,
432-
exp: &def::Export) {
433-
let exp_node_id = if let Some(n) = ecx.tcx.map.as_local_node_id(exp.def_id) {
434-
n
435-
} else {
436-
// Before the refactor that introducd `as_local_node_id`, we
437-
// were just extracting the node and checking into the
438-
// ast-map. Since the node might have been from another crate,
439-
// this was a tenuous thing to do at best. Anyway, I'm not
440-
// 100% clear on why it's ok to ignore things from other
441-
// crates, but it seems to be what we were doing pre-refactor.
442-
// -nmatsakis
443-
return;
444-
};
445-
446-
if let Some(ast_map::NodeItem(item)) = ecx.tcx.map.find(exp_node_id) {
447-
let path_differs = ecx.tcx.map.with_path(exp_node_id, |path| {
448-
let (mut a, mut b) = (path, mod_path.clone());
449-
loop {
450-
match (a.next(), b.next()) {
451-
(None, None) => return true,
452-
(None, _) | (_, None) => return false,
453-
(Some(x), Some(y)) => if x != y { return false },
454-
}
455-
}
456-
});
457-
458-
//
459-
// We don't need to reexport static methods on items
460-
// declared in the same module as our `pub use ...` since
461-
// that's done when we encode the item itself.
462-
//
463-
// The only exception is when the reexport *changes* the
464-
// name e.g. `pub use Foo = self::Bar` -- we have
465-
// encoded metadata for static methods relative to Bar,
466-
// but not yet for Foo.
467-
//
468-
if path_differs || item.name != exp.name {
469-
if !encode_reexported_static_base_methods(ecx, rbml_w, exp) {
470-
if encode_reexported_static_trait_methods(ecx, rbml_w, exp) {
471-
debug!("(encode reexported static methods) {} [trait]",
472-
item.name);
473-
}
474-
}
475-
else {
476-
debug!("(encode reexported static methods) {} [base]",
477-
item.name);
478-
}
479-
}
480-
}
481-
}
482-
483369
/// Iterates through "auxiliary node IDs", which are node IDs that describe
484370
/// top-level items that are sub-items of the given item. Specifically:
485371
///
@@ -507,8 +393,7 @@ fn each_auxiliary_node_id<F>(item: &hir::Item, callback: F) -> bool where
507393

508394
fn encode_reexports(ecx: &EncodeContext,
509395
rbml_w: &mut Encoder,
510-
id: NodeId,
511-
path: PathElems) {
396+
id: NodeId) {
512397
debug!("(encoding info for module) encoding reexports for {}", id);
513398
match ecx.reexports.get(&id) {
514399
Some(exports) => {
@@ -525,7 +410,6 @@ fn encode_reexports(ecx: &EncodeContext,
525410
rbml_w.wr_tagged_str(tag_items_data_item_reexport_name,
526411
&exp.name.as_str());
527412
rbml_w.end_tag();
528-
encode_reexported_static_methods(ecx, rbml_w, path.clone(), exp);
529413
}
530414
},
531415
None => debug!("(encoding info for module) found no reexports for {}", id),
@@ -576,7 +460,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
576460
// Encode the reexports of this module, if this module is public.
577461
if vis == hir::Public {
578462
debug!("(encoding info for module) encoding reexports for {}", id);
579-
encode_reexports(ecx, rbml_w, id, path);
463+
encode_reexports(ecx, rbml_w, id);
580464
}
581465
encode_attributes(rbml_w, attrs);
582466

@@ -1930,7 +1814,7 @@ fn encode_misc_info(ecx: &EncodeContext,
19301814
}
19311815

19321816
// Encode reexports for the root module.
1933-
encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(LinkedPath::empty()));
1817+
encode_reexports(ecx, rbml_w, 0);
19341818

19351819
rbml_w.end_tag();
19361820
rbml_w.end_tag();

0 commit comments

Comments
 (0)