diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index f848cf638f8b..2f115b8e836e 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1553,18 +1553,12 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity, ast::impure_fn. { let sess = ccx.tcx.sess; alt ccx.tcx.def_map.find(callee.id) { - some(ast::def_fn(_, ast::unsafe_fn.)) { - if sess.get_opts().check_unsafe { - ccx.tcx.sess.span_fatal( - sp, - "safe function calls function marked unsafe"); - } - } + some(ast::def_fn(_, ast::unsafe_fn.)) | some(ast::def_native_fn(_, ast::unsafe_fn.)) { if sess.get_opts().check_unsafe { ccx.tcx.sess.span_fatal( sp, - "native functions can only be invoked from unsafe code"); + "safe function calls function marked unsafe"); } } _ { diff --git a/src/test/compile-fail/native-unsafe-fn-called.rs b/src/test/compile-fail/native-unsafe-fn-called.rs index 3104884130b1..6e9d7ac18fcc 100644 --- a/src/test/compile-fail/native-unsafe-fn-called.rs +++ b/src/test/compile-fail/native-unsafe-fn-called.rs @@ -1,6 +1,5 @@ // -*- rust -*- // error-pattern: safe function calls function marked unsafe - native "cdecl" mod test { unsafe fn free(); }