Skip to content

Commit 6943b38

Browse files
committed
rustc: Add crust functions to the AST
1 parent acabd82 commit 6943b38

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/comp/metadata/encoder.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,12 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
312312
}
313313

314314
fn purity_fn_family(p: purity) -> char {
315-
alt p { unsafe_fn { 'u' } pure_fn { 'p' } impure_fn { 'f' } }
315+
alt p {
316+
unsafe_fn { 'u' }
317+
pure_fn { 'p' }
318+
impure_fn { 'f' }
319+
crust_fn { 'c' }
320+
}
316321
}
317322

318323
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,

src/comp/middle/typeck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ fn require_unsafe(sess: session, f_purity: ast::purity, sp: span) {
15351535
fn require_impure(sess: session, f_purity: ast::purity, sp: span) {
15361536
alt f_purity {
15371537
ast::unsafe_fn { ret; }
1538-
ast::impure_fn { ret; }
1538+
ast::impure_fn | ast::crust_fn { ret; }
15391539
ast::pure_fn {
15401540
sess.span_err(sp, "Found impure expression in pure function decl");
15411541
}
@@ -1568,7 +1568,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
15681568
}
15691569
};
15701570
alt (caller_purity, callee_purity) {
1571-
(ast::impure_fn, ast::unsafe_fn) {
1571+
(ast::impure_fn, ast::unsafe_fn) | (ast::crust_fn, ast::unsafe_fn) {
15721572
ccx.tcx.sess.span_err(sp, "safe function calls function marked \
15731573
unsafe");
15741574
}

src/comp/syntax/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ enum purity {
407407
pure_fn, // declared with "pure fn"
408408
unsafe_fn, // declared with "unsafe fn"
409409
impure_fn, // declared with "fn"
410+
crust_fn, // declared with "crust fn"
410411
}
411412

412413
enum ret_style {

src/comp/syntax/print/pprust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident,
11991199
ast::impure_fn { head(s, "fn"); }
12001200
ast::unsafe_fn { head(s, "unsafe fn"); }
12011201
ast::pure_fn { head(s, "pure fn"); }
1202+
ast::crust_fn { head(s, "crust fn"); }
12021203
}
12031204
word(s.s, name);
12041205
print_type_params(s, typarams);

0 commit comments

Comments
 (0)