@@ -134,8 +134,8 @@ impl AstConv for CrateCtxt {
134
134
Some ( & ast_map:: node_item( item, _) ) => {
135
135
ty_of_item ( self , item)
136
136
}
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 )
139
139
}
140
140
ref x => {
141
141
self . tcx . sess . bug ( fmt ! ( "unexpected sort of item \
@@ -932,7 +932,20 @@ pub fn convert_foreign(ccx: &CrateCtxt, i: @ast::foreign_item) {
932
932
// As above, this call populates the type table with the converted
933
933
// type of the foreign item. We simply write it into the node type
934
934
// 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) ;
936
949
write_ty_to_tcx ( ccx. tcx , i. id , tpt. ty ) ;
937
950
ccx. tcx . tcache . insert ( local_def ( i. id ) , tpt) ;
938
951
}
@@ -1103,14 +1116,17 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: @ast::item)
1103
1116
}
1104
1117
}
1105
1118
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
+ {
1108
1123
match it.node {
1109
1124
ast::foreign_item_fn(ref fn_decl, _, ref generics) => {
1110
1125
ty_of_foreign_fn_decl(ccx,
1111
1126
fn_decl,
1112
1127
local_def(it.id),
1113
- generics)
1128
+ generics,
1129
+ abis)
1114
1130
}
1115
1131
ast::foreign_item_const(t) => {
1116
1132
ty::ty_param_bounds_and_ty {
@@ -1197,7 +1213,8 @@ pub fn ty_generics(ccx: &CrateCtxt,
1197
1213
pub fn ty_of_foreign_fn_decl ( ccx : & CrateCtxt ,
1198
1214
decl : & ast:: fn_decl ,
1199
1215
def_id : ast:: def_id ,
1200
- ast_generics : & ast:: Generics )
1216
+ ast_generics : & ast:: Generics ,
1217
+ abis : AbiSet )
1201
1218
-> ty:: ty_param_bounds_and_ty {
1202
1219
let ty_generics = ty_generics ( ccx, None , ast_generics, 0 ) ;
1203
1220
let region_param_names = RegionParamNames :: from_generics ( ast_generics) ;
@@ -1208,7 +1225,7 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
1208
1225
let t_fn = ty:: mk_bare_fn (
1209
1226
ccx. tcx ,
1210
1227
ty:: BareFnTy {
1211
- abis : AbiSet :: Rust ( ) ,
1228
+ abis : abis ,
1212
1229
purity : ast:: unsafe_fn,
1213
1230
sig : ty:: FnSig { bound_lifetime_names : opt_vec:: Empty ,
1214
1231
inputs : input_tys,
0 commit comments