Skip to content

Commit 13a5ea0

Browse files
Use new symbol names for items of various kinds.
1 parent b474c10 commit 13a5ea0

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/librustc_trans/trans/base.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ pub use self::ValueOrigin::*;
2929
use super::CrateTranslation;
3030
use super::ModuleTranslation;
3131

32-
use back::link::mangle_exported_name;
33-
use back::{link, abi};
32+
use back::{link, abi, symbol_names};
3433
use lint;
3534
use llvm::{BasicBlockRef, Linkage, ValueRef, Vector, get_param};
3635
use llvm;
@@ -2730,16 +2729,17 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
27302729
// Use provided name
27312730
Some(name) => name.to_string(),
27322731
_ => {
2733-
let path = ccx.tcx().map.def_path_from_id(id);
27342732
if attr::contains_name(attrs, "no_mangle") {
27352733
// Don't mangle
2734+
let path = ccx.tcx().map.def_path_from_id(id);
27362735
path.last().unwrap().data.to_string()
27372736
} else {
27382737
match weak_lang_items::link_name(attrs) {
27392738
Some(name) => name.to_string(),
27402739
None => {
27412740
// Usual name mangling
2742-
mangle_exported_name(ccx, path, ty, id)
2741+
let def_id = ccx.tcx().map.local_def_id(id);
2742+
symbol_names::exported_name(ccx, def_id, &[ty])
27432743
}
27442744
}
27452745
}
@@ -2763,7 +2763,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
27632763
debug!("get_item_val: id={} item={:?}", id, item);
27642764
let val = match item {
27652765
hir_map::NodeItem(i) => {
2766-
let ty = ccx.tcx().node_id_to_type(i.id);
2766+
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(i.id));
27672767
let sym = || exported_name(ccx, id, ty, &i.attrs);
27682768

27692769
let v = match i.node {
@@ -2835,7 +2835,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
28352835
match ni.node {
28362836
hir::ForeignItemFn(..) => {
28372837
let abi = ccx.tcx().map.get_foreign_abi(id);
2838-
let ty = ccx.tcx().node_id_to_type(ni.id);
2838+
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(ni.id));
28392839
let name = foreign::link_name(&ni);
28402840
foreign::register_foreign_item_fn(ccx, abi, ty, &name, &ni.attrs)
28412841
}
@@ -2853,7 +2853,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
28532853
v.node.data.fields()
28542854
};
28552855
assert!(!fields.is_empty());
2856-
let ty = ccx.tcx().node_id_to_type(id);
2856+
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(id));
28572857
let parent = ccx.tcx().map.get_parent(id);
28582858
let enm = ccx.tcx().map.expect_item(parent);
28592859
let sym = exported_name(ccx, id, ty, &enm.attrs);
@@ -2877,7 +2877,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
28772877
};
28782878
let parent = ccx.tcx().map.get_parent(id);
28792879
let struct_item = ccx.tcx().map.expect_item(parent);
2880-
let ty = ccx.tcx().node_id_to_type(ctor_id);
2880+
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(ctor_id));
28812881
let sym = exported_name(ccx, id, ty, &struct_item.attrs);
28822882
let llfn = register_fn(ccx, struct_item.span, sym, ctor_id, ty);
28832883
attributes::inline(llfn, attributes::InlineAttr::Hint);
@@ -2907,7 +2907,7 @@ fn register_method(ccx: &CrateContext,
29072907
attrs: &[ast::Attribute],
29082908
span: Span)
29092909
-> ValueRef {
2910-
let mty = ccx.tcx().node_id_to_type(id);
2910+
let mty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(id));
29112911

29122912
let sym = exported_name(ccx, id, mty, &attrs);
29132913

src/test/run-pass/issue-17718.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// aux-build:issue-17718.rs
11+
// aux-build:issue-17718-aux.rs
1212

1313

1414
#![feature(core)]
1515
#![feature(const_fn)]
1616

17-
extern crate issue_17718 as other;
17+
extern crate issue_17718_aux as other;
1818

1919
use std::sync::atomic::{AtomicUsize, Ordering};
2020

0 commit comments

Comments
 (0)