rustc: Add crust functions to the AST

This commit is contained in:
Brian Anderson 2012-02-10 13:39:15 -08:00
parent acabd821d2
commit 6943b38e4f
4 changed files with 10 additions and 3 deletions

View file

@ -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,

View file

@ -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");
}

View file

@ -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 {

View file

@ -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);