diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 1386e23b77d..da73f25b6d1 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -892,7 +892,8 @@ fn encode_info_for_method(ecx: &EncodeContext, IITraitItemRef(local_def(parent_id), RequiredInlinedTraitItemRef( &*ast_method))); - } else { + } + if !any_types { encode_symbol(ecx, rbml_w, m.def_id.node); } encode_method_argument_names(rbml_w, &*ast_method.pe_fn_decl()); @@ -1047,7 +1048,8 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_attributes(rbml_w, item.attrs.as_slice()); if tps_len > 0u || should_inline(item.attrs.as_slice()) { encode_inlined_item(ecx, rbml_w, IIItemRef(item)); - } else { + } + if tps_len == 0 { encode_symbol(ecx, rbml_w, item.id); } encode_visibility(rbml_w, vis); @@ -1411,9 +1413,8 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext, encode_name(rbml_w, nitem.ident.name); if abi == abi::RustIntrinsic { encode_inlined_item(ecx, rbml_w, IIForeignRef(nitem)); - } else { - encode_symbol(ecx, rbml_w, nitem.id); } + encode_symbol(ecx, rbml_w, nitem.id); } ForeignItemStatic(_, mutbl) => { if mutbl { diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index d56fb31fb20..c1b92f71878 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2554,6 +2554,15 @@ pub fn create_entry_wrapper(ccx: &CrateContext, fn exported_name(ccx: &CrateContext, id: ast::NodeId, ty: ty::t, attrs: &[ast::Attribute]) -> String { + match ccx.external_srcs().borrow().find(&id) { + Some(&did) => { + let sym = csearch::get_symbol(&ccx.sess().cstore, did); + debug!("found item {} in other crate...", sym); + return sym; + } + None => {} + } + match attr::first_attr_value_str_by_name(attrs, "export_name") { // Use provided name Some(name) => name.get().to_string(), @@ -2597,16 +2606,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { // using the current crate's name/version // information in the hash of the symbol debug!("making {}", sym); - let (sym, is_local) = { - match ccx.external_srcs().borrow().find(&i.id) { - Some(&did) => { - debug!("but found in other crate..."); - (csearch::get_symbol(&ccx.sess().cstore, - did), false) - } - None => (sym, true) - } - }; + let is_local = !ccx.external_srcs().borrow().contains_key(&id); // We need the translated value here, because for enums the // LLVM type is not fully determined by the Rust type.