comp: allowed the declaration of pure fn's in native mods

This is especially useful for the native calls in std::math

This commit does NOT yet point to new snapshots
This commit is contained in:
Stefan Plantikow 2011-11-22 19:51:05 +01:00
parent fedb775fbb
commit 148a6c1a38
2 changed files with 4 additions and 0 deletions

View File

@ -1501,6 +1501,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
ast::pure_fn. {
alt ccx.tcx.def_map.find(callee.id) {
some(ast::def_fn(_, ast::pure_fn.)) { ret; }
some(ast::def_native_fn(_, ast::pure_fn.)) { ret; }
_ {
ccx.tcx.sess.span_err
(sp, "pure function calls function not known to be pure");

View File

@ -1975,6 +1975,9 @@ fn parse_native_item(p: parser, attrs: [ast::attribute]) ->
ret parse_item_native_type(p, attrs);
} else if eat_word(p, "fn") {
ret parse_item_native_fn(p, attrs, ast::impure_fn);
} else if eat_word(p, "pure") {
expect_word(p, "fn");
ret parse_item_native_fn(p, attrs, ast::pure_fn);
} else if eat_word(p, "unsafe") {
expect_word(p, "fn");
ret parse_item_native_fn(p, attrs, ast::unsafe_fn);