diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2011-10-11 14:52:38 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-10-12 14:39:34 -0700 |
| commit | 212707ce8440205d5f49b0a274caf629bf118de0 (patch) | |
| tree | 329d516a27e9975b7036835bbf4826ee9e40124b /src/comp/syntax/parse | |
| parent | 24b201fa48558832f13c41f1307d824ee26915eb (diff) | |
| download | rust-212707ce8440205d5f49b0a274caf629bf118de0.tar.gz rust-212707ce8440205d5f49b0a274caf629bf118de0.zip | |
make native functions markable as unsafe and incorporate that
into the type check
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 11 |
1 files changed, 7 insertions, 4 deletions
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()); } } |
