about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-10 13:39:15 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-14 11:24:09 -0800
commit6943b38e4fd75dfd3c6ff80b96060ec9a39e01e9 (patch)
tree68375cf27e462c6c3e9e1ae102bee7060f3345ec /src/comp
parentacabd821d2c3503c087b2ce2bd784c14f48cb407 (diff)
downloadrust-6943b38e4fd75dfd3c6ff80b96060ec9a39e01e9.tar.gz
rust-6943b38e4fd75dfd3c6ff80b96060ec9a39e01e9.zip
rustc: Add crust functions to the AST
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/metadata/encoder.rs7
-rw-r--r--src/comp/middle/typeck.rs4
-rw-r--r--src/comp/syntax/ast.rs1
-rw-r--r--src/comp/syntax/print/pprust.rs1
4 files changed, 10 insertions, 3 deletions
diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs
index 650d1fcf975..96f283c5922 100644
--- a/src/comp/metadata/encoder.rs
+++ b/src/comp/metadata/encoder.rs
@@ -312,7 +312,12 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
 }
 
 fn purity_fn_family(p: purity) -> char {
-    alt p { unsafe_fn { 'u' } pure_fn { 'p' } impure_fn { 'f' } }
+    alt p {
+      unsafe_fn { 'u' }
+      pure_fn { 'p' }
+      impure_fn { 'f' }
+      crust_fn { 'c' }
+    }
 }
 
 fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index caa4079a9d4..57b0333ada9 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -1535,7 +1535,7 @@ fn require_unsafe(sess: session, f_purity: ast::purity, sp: span) {
 fn require_impure(sess: session, f_purity: ast::purity, sp: span) {
     alt f_purity {
       ast::unsafe_fn { ret; }
-      ast::impure_fn { ret; }
+      ast::impure_fn | ast::crust_fn { ret; }
       ast::pure_fn {
         sess.span_err(sp, "Found impure expression in pure function decl");
       }
@@ -1568,7 +1568,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
       }
     };
     alt (caller_purity, callee_purity) {
-      (ast::impure_fn, ast::unsafe_fn) {
+      (ast::impure_fn, ast::unsafe_fn) | (ast::crust_fn, ast::unsafe_fn) {
         ccx.tcx.sess.span_err(sp, "safe function calls function marked \
                                    unsafe");
       }
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs
index 26a309d37f5..2ab7059a2a4 100644
--- a/src/comp/syntax/ast.rs
+++ b/src/comp/syntax/ast.rs
@@ -407,6 +407,7 @@ enum purity {
     pure_fn, // declared with "pure fn"
     unsafe_fn, // declared with "unsafe fn"
     impure_fn, // declared with "fn"
+    crust_fn, // declared with "crust fn"
 }
 
 enum ret_style {
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 047653cc4c9..b0ed7ceed00 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -1199,6 +1199,7 @@ fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident,
       ast::impure_fn { head(s, "fn"); }
       ast::unsafe_fn { head(s, "unsafe fn"); }
       ast::pure_fn { head(s, "pure fn"); }
+      ast::crust_fn { head(s, "crust fn"); }
     }
     word(s.s, name);
     print_type_params(s, typarams);