@@ -21,6 +21,7 @@ use middle::trans::cabi;
21
21
use middle:: trans:: build:: * ;
22
22
use middle:: trans:: builder:: noname;
23
23
use middle:: trans:: common:: * ;
24
+ use middle:: trans:: llrepr:: LlvmRepr ;
24
25
use middle:: trans:: type_of:: * ;
25
26
use middle:: trans:: type_of;
26
27
use middle:: ty;
@@ -399,7 +400,29 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @mut CrateContext,
399
400
ccx, vec:: append_one ( ( * path) . clone ( ) , ast_map:: path_name (
400
401
special_idents:: clownshoe_abi
401
402
) ) ) ;
402
- let llty = type_of_fn_from_ty ( ccx, t) ;
403
+
404
+ // Compute the LLVM type that the function would have if it
405
+ // were just a normal Rust function. This will be the type of
406
+ // the wrappee fn.
407
+ let llty = match ty:: get ( t) . sty {
408
+ ty:: ty_bare_fn( ref f) => {
409
+ assert ! ( !f. abis. is_rust( ) && !f. abis. is_intrinsic( ) ) ;
410
+ type_of_rust_fn ( ccx, f. sig . inputs , f. sig . output )
411
+ }
412
+ _ => {
413
+ ccx. sess . bug ( fmt ! ( "build_rust_fn: extern fn %s has ty %s, \
414
+ expected a bare fn ty",
415
+ path. repr( tcx) ,
416
+ t. repr( tcx) ) ) ;
417
+ }
418
+ } ;
419
+
420
+ debug ! ( "build_rust_fn: path=%s id=%? t=%s llty=%s" ,
421
+ path. repr( tcx) ,
422
+ id,
423
+ t. repr( tcx) ,
424
+ llty. llrepr( ccx) ) ;
425
+
403
426
let llfndecl = base:: decl_internal_cdecl_fn ( ccx. llmod , ps, llty) ;
404
427
base:: trans_fn ( ccx,
405
428
( * path) . clone ( ) ,
0 commit comments