@@ -29,8 +29,7 @@ pub use self::ValueOrigin::*;
29
29
use super :: CrateTranslation ;
30
30
use super :: ModuleTranslation ;
31
31
32
- use back:: link:: mangle_exported_name;
33
- use back:: { link, abi} ;
32
+ use back:: { link, abi, symbol_names} ;
34
33
use lint;
35
34
use llvm:: { BasicBlockRef , Linkage , ValueRef , Vector , get_param} ;
36
35
use llvm;
@@ -2730,16 +2729,17 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
2730
2729
// Use provided name
2731
2730
Some ( name) => name. to_string ( ) ,
2732
2731
_ => {
2733
- let path = ccx. tcx ( ) . map . def_path_from_id ( id) ;
2734
2732
if attr:: contains_name ( attrs, "no_mangle" ) {
2735
2733
// Don't mangle
2734
+ let path = ccx. tcx ( ) . map . def_path_from_id ( id) ;
2736
2735
path. last ( ) . unwrap ( ) . data . to_string ( )
2737
2736
} else {
2738
2737
match weak_lang_items:: link_name ( attrs) {
2739
2738
Some ( name) => name. to_string ( ) ,
2740
2739
None => {
2741
2740
// 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] )
2743
2743
}
2744
2744
}
2745
2745
}
@@ -2763,7 +2763,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2763
2763
debug ! ( "get_item_val: id={} item={:?}" , id, item) ;
2764
2764
let val = match item {
2765
2765
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 ) ) ;
2767
2767
let sym = || exported_name ( ccx, id, ty, & i. attrs ) ;
2768
2768
2769
2769
let v = match i. node {
@@ -2835,7 +2835,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2835
2835
match ni. node {
2836
2836
hir:: ForeignItemFn ( ..) => {
2837
2837
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 ) ) ;
2839
2839
let name = foreign:: link_name ( & ni) ;
2840
2840
foreign:: register_foreign_item_fn ( ccx, abi, ty, & name, & ni. attrs )
2841
2841
}
@@ -2853,7 +2853,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2853
2853
v. node . data . fields ( )
2854
2854
} ;
2855
2855
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) ) ;
2857
2857
let parent = ccx. tcx ( ) . map . get_parent ( id) ;
2858
2858
let enm = ccx. tcx ( ) . map . expect_item ( parent) ;
2859
2859
let sym = exported_name ( ccx, id, ty, & enm. attrs ) ;
@@ -2877,7 +2877,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2877
2877
} ;
2878
2878
let parent = ccx. tcx ( ) . map . get_parent ( id) ;
2879
2879
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) ) ;
2881
2881
let sym = exported_name ( ccx, id, ty, & struct_item. attrs ) ;
2882
2882
let llfn = register_fn ( ccx, struct_item. span , sym, ctor_id, ty) ;
2883
2883
attributes:: inline ( llfn, attributes:: InlineAttr :: Hint ) ;
@@ -2907,7 +2907,7 @@ fn register_method(ccx: &CrateContext,
2907
2907
attrs : & [ ast:: Attribute ] ,
2908
2908
span : Span )
2909
2909
-> 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) ) ;
2911
2911
2912
2912
let sym = exported_name ( ccx, id, mty, & attrs) ;
2913
2913
0 commit comments