@@ -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;
@@ -2732,16 +2731,17 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
2732
2731
// Use provided name
2733
2732
Some ( name) => name. to_string ( ) ,
2734
2733
_ => {
2735
- let path = ccx. tcx ( ) . map . def_path_from_id ( id) ;
2736
2734
if attr:: contains_name ( attrs, "no_mangle" ) {
2737
2735
// Don't mangle
2736
+ let path = ccx. tcx ( ) . map . def_path_from_id ( id) ;
2738
2737
path. last ( ) . unwrap ( ) . data . to_string ( )
2739
2738
} else {
2740
2739
match weak_lang_items:: link_name ( attrs) {
2741
2740
Some ( name) => name. to_string ( ) ,
2742
2741
None => {
2743
2742
// Usual name mangling
2744
- mangle_exported_name ( ccx, path, ty, id)
2743
+ let def_id = ccx. tcx ( ) . map . local_def_id ( id) ;
2744
+ symbol_names:: exported_name ( ccx, def_id, & [ ty] )
2745
2745
}
2746
2746
}
2747
2747
}
@@ -2764,7 +2764,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2764
2764
debug ! ( "get_item_val: id={} item={:?}" , id, item) ;
2765
2765
let val = match item {
2766
2766
hir_map:: NodeItem ( i) => {
2767
- let ty = ccx. tcx ( ) . node_id_to_type ( i. id ) ;
2767
+ let ty = ccx. tcx ( ) . erase_regions ( & ccx . tcx ( ) . node_id_to_type ( i. id ) ) ;
2768
2768
let sym = || exported_name ( ccx, id, ty, & i. attrs ) ;
2769
2769
2770
2770
let v = match i. node {
@@ -2836,7 +2836,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2836
2836
match ni. node {
2837
2837
hir:: ForeignItemFn ( ..) => {
2838
2838
let abi = ccx. tcx ( ) . map . get_foreign_abi ( id) ;
2839
- let ty = ccx. tcx ( ) . node_id_to_type ( ni. id ) ;
2839
+ let ty = ccx. tcx ( ) . erase_regions ( & ccx . tcx ( ) . node_id_to_type ( ni. id ) ) ;
2840
2840
let name = foreign:: link_name ( & ni) ;
2841
2841
foreign:: register_foreign_item_fn ( ccx, abi, ty, & name, & ni. attrs )
2842
2842
}
@@ -2854,7 +2854,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2854
2854
v. node . data . fields ( )
2855
2855
} ;
2856
2856
assert ! ( !fields. is_empty( ) ) ;
2857
- let ty = ccx. tcx ( ) . node_id_to_type ( id) ;
2857
+ let ty = ccx. tcx ( ) . erase_regions ( & ccx . tcx ( ) . node_id_to_type ( id) ) ;
2858
2858
let parent = ccx. tcx ( ) . map . get_parent ( id) ;
2859
2859
let enm = ccx. tcx ( ) . map . expect_item ( parent) ;
2860
2860
let sym = exported_name ( ccx, id, ty, & enm. attrs ) ;
@@ -2878,7 +2878,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
2878
2878
} ;
2879
2879
let parent = ccx. tcx ( ) . map . get_parent ( id) ;
2880
2880
let struct_item = ccx. tcx ( ) . map . expect_item ( parent) ;
2881
- let ty = ccx. tcx ( ) . node_id_to_type ( ctor_id) ;
2881
+ let ty = ccx. tcx ( ) . erase_regions ( & ccx . tcx ( ) . node_id_to_type ( ctor_id) ) ;
2882
2882
let sym = exported_name ( ccx, id, ty, & struct_item. attrs ) ;
2883
2883
let llfn = register_fn ( ccx, struct_item. span , sym, ctor_id, ty) ;
2884
2884
attributes:: inline ( llfn, attributes:: InlineAttr :: Hint ) ;
@@ -2908,7 +2908,7 @@ fn register_method(ccx: &CrateContext,
2908
2908
attrs : & [ ast:: Attribute ] ,
2909
2909
span : Span )
2910
2910
-> ValueRef {
2911
- let mty = ccx. tcx ( ) . node_id_to_type ( id) ;
2911
+ let mty = ccx. tcx ( ) . erase_regions ( & ccx . tcx ( ) . node_id_to_type ( id) ) ;
2912
2912
2913
2913
let sym = exported_name ( ccx, id, mty, & attrs) ;
2914
2914
0 commit comments