@@ -134,8 +134,8 @@ impl AstConv for CrateCtxt {
134134 Some ( & ast_map:: node_item( item, _) ) => {
135135 ty_of_item ( self , item)
136136 }
137- Some ( & ast_map:: node_foreign_item( foreign_item, _ , _, _) ) => {
138- ty_of_foreign_item ( self , foreign_item)
137+ Some ( & ast_map:: node_foreign_item( foreign_item, abis , _, _) ) => {
138+ ty_of_foreign_item ( self , foreign_item, abis )
139139 }
140140 ref x => {
141141 self . tcx . sess . bug ( fmt ! ( "unexpected sort of item \
@@ -932,7 +932,20 @@ pub fn convert_foreign(ccx: &CrateCtxt, i: @ast::foreign_item) {
932932 // As above, this call populates the type table with the converted
933933 // type of the foreign item. We simply write it into the node type
934934 // table.
935- let tpt = ty_of_foreign_item ( ccx, i) ;
935+
936+ // For reasons I cannot fully articulate, I do so hate the AST
937+ // map, and I regard each time that I use it as a personal and
938+ // moral failing, but at the moment it seems like the only
939+ // convenient way to extract the ABI. - ndm
940+ let abis = match ccx. tcx . items . find ( & i. id ) {
941+ Some ( & ast_map:: node_foreign_item( _, abis, _, _) ) => abis,
942+ ref x => {
943+ ccx. tcx . sess . bug ( fmt ! ( "unexpected sort of item \
944+ in get_item_ty(): %?", ( * x) ) ) ;
945+ }
946+ } ;
947+
948+ let tpt = ty_of_foreign_item ( ccx, i, abis) ;
936949 write_ty_to_tcx ( ccx. tcx , i. id , tpt. ty ) ;
937950 ccx. tcx . tcache . insert ( local_def ( i. id ) , tpt) ;
938951}
@@ -1103,14 +1116,17 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: @ast::item)
11031116 }
11041117}
11051118
1106- pub fn ty_of_foreign_item(ccx: &CrateCtxt, it: @ast::foreign_item)
1107- -> ty::ty_param_bounds_and_ty {
1119+ pub fn ty_of_foreign_item(ccx: &CrateCtxt,
1120+ it: @ast::foreign_item,
1121+ abis: AbiSet) -> ty::ty_param_bounds_and_ty
1122+ {
11081123 match it.node {
11091124 ast::foreign_item_fn(ref fn_decl, _, ref generics) => {
11101125 ty_of_foreign_fn_decl(ccx,
11111126 fn_decl,
11121127 local_def(it.id),
1113- generics)
1128+ generics,
1129+ abis)
11141130 }
11151131 ast::foreign_item_const(t) => {
11161132 ty::ty_param_bounds_and_ty {
@@ -1197,7 +1213,8 @@ pub fn ty_generics(ccx: &CrateCtxt,
11971213pub fn ty_of_foreign_fn_decl ( ccx : & CrateCtxt ,
11981214 decl : & ast:: fn_decl ,
11991215 def_id : ast:: def_id ,
1200- ast_generics : & ast:: Generics )
1216+ ast_generics : & ast:: Generics ,
1217+ abis : AbiSet )
12011218 -> ty:: ty_param_bounds_and_ty {
12021219 let ty_generics = ty_generics ( ccx, None , ast_generics, 0 ) ;
12031220 let region_param_names = RegionParamNames :: from_generics ( ast_generics) ;
@@ -1208,7 +1225,7 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
12081225 let t_fn = ty:: mk_bare_fn (
12091226 ccx. tcx ,
12101227 ty:: BareFnTy {
1211- abis : AbiSet :: Rust ( ) ,
1228+ abis : abis ,
12121229 purity : ast:: unsafe_fn,
12131230 sig : ty:: FnSig { bound_lifetime_names : opt_vec:: Empty ,
12141231 inputs : input_tys,
0 commit comments