Skip to content

Commit 148a6c1

Browse files
committed
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
1 parent fedb775 commit 148a6c1

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/comp/middle/typeck.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
15011501
ast::pure_fn. {
15021502
alt ccx.tcx.def_map.find(callee.id) {
15031503
some(ast::def_fn(_, ast::pure_fn.)) { ret; }
1504+
some(ast::def_native_fn(_, ast::pure_fn.)) { ret; }
15041505
_ {
15051506
ccx.tcx.sess.span_err
15061507
(sp, "pure function calls function not known to be pure");

src/comp/syntax/parse/parser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,9 @@ fn parse_native_item(p: parser, attrs: [ast::attribute]) ->
19751975
ret parse_item_native_type(p, attrs);
19761976
} else if eat_word(p, "fn") {
19771977
ret parse_item_native_fn(p, attrs, ast::impure_fn);
1978+
} else if eat_word(p, "pure") {
1979+
expect_word(p, "fn");
1980+
ret parse_item_native_fn(p, attrs, ast::pure_fn);
19781981
} else if eat_word(p, "unsafe") {
19791982
expect_word(p, "fn");
19801983
ret parse_item_native_fn(p, attrs, ast::unsafe_fn);

0 commit comments

Comments
 (0)