From 212707ce8440205d5f49b0a274caf629bf118de0 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 11 Oct 2011 14:52:38 -0700 Subject: make native functions markable as unsafe and incorporate that into the type check --- src/comp/syntax/parse/parser.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/comp/syntax/parse') diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index ab573691720..7a1e61f27ba 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1972,11 +1972,11 @@ fn parse_item_native_type(p: parser, attrs: [ast::attribute]) -> span: ast_util::mk_sp(t.lo, hi)}; } -fn parse_item_native_fn(p: parser, attrs: [ast::attribute]) -> - @ast::native_item { +fn parse_item_native_fn(p: parser, attrs: [ast::attribute], + purity: ast::purity) -> @ast::native_item { let lo = p.get_last_lo_pos(); let t = parse_fn_header(p); - let decl = parse_fn_decl(p, ast::impure_fn, ast::il_normal); + let decl = parse_fn_decl(p, purity, ast::il_normal); let link_name = none; if p.peek() == token::EQ { p.bump(); link_name = some(parse_str(p)); } let hi = p.get_hi_pos(); @@ -1993,7 +1993,10 @@ fn parse_native_item(p: parser, attrs: [ast::attribute]) -> if eat_word(p, "type") { ret parse_item_native_type(p, attrs); } else if eat_word(p, "fn") { - ret parse_item_native_fn(p, attrs); + ret parse_item_native_fn(p, attrs, ast::impure_fn); + } else if eat_word(p, "unsafe") { + expect_word(p, "fn"); + ret parse_item_native_fn(p, attrs, ast::unsafe_fn); } else { unexpected(p, p.peek()); } } -- cgit 1.4.1-3-g733a5