about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/comp/middle/trans/base.rs14
-rw-r--r--src/comp/middle/trans/native.rs7
2 files changed, 15 insertions, 6 deletions
diff --git a/src/comp/middle/trans/base.rs b/src/comp/middle/trans/base.rs
index 2750a345ae0..a1656d50e8e 100644
--- a/src/comp/middle/trans/base.rs
+++ b/src/comp/middle/trans/base.rs
@@ -4465,15 +4465,19 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
     };
     alt item.node {
       ast::item_fn(decl, tps, body) {
-        alt ccx.item_ids.find(item.id) {
-          some(llfndecl) {
-            trans_fn(ccx, *path + [path_name(item.ident)], decl, body,
-                     llfndecl, no_self, tps, none, item.id);
-          }
+        let llfndecl = alt ccx.item_ids.find(item.id) {
+          some(llfndecl) { llfndecl }
           _ {
             ccx.sess.span_fatal(item.span,
                                 "unbound function item in trans_item");
           }
+        };
+        if decl.purity != ast::crust_fn  {
+            trans_fn(ccx, *path + [path_name(item.ident)], decl, body,
+                     llfndecl, no_self, tps, none, item.id);
+        } else {
+            native::trans_crust_fn(ccx, *path + [path_name(item.ident)],
+                                   decl, body, llfndecl, item.id);
         }
       }
       ast::item_impl(tps, _, _, ms) {
diff --git a/src/comp/middle/trans/native.rs b/src/comp/middle/trans/native.rs
index 67d320fa668..93f753455bf 100644
--- a/src/comp/middle/trans/native.rs
+++ b/src/comp/middle/trans/native.rs
@@ -7,7 +7,7 @@ import common::*;
 import build::*;
 import base::*;
 
-export link_name, trans_native_mod;
+export link_name, trans_native_mod, trans_crust_fn;
 
 fn link_name(i: @ast::native_item) -> str {
     alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
@@ -189,3 +189,8 @@ fn trans_native_mod(ccx: @crate_ctxt,
       }
     }
 }
+
+fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
+                  body: ast::blk, llfndecl: ValueRef, id: ast::node_id) {
+    trans_fn(ccx, path, decl, body, llfndecl, no_self, [], none, id)
+}
\ No newline at end of file