From c582e3eb820feb0e7315054ec229e35c44a34719 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 31 May 2013 11:31:38 -0700 Subject: [PATCH] librustc: Don't require `pub extern` to make extern functions visible --- src/librustc/middle/privacy.rs | 2 +- src/test/run-pass/pub-extern-privacy.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/pub-extern-privacy.rs diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 5f88c25653d60..0f00e9d596e17 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -200,7 +200,7 @@ pub fn check_crate(tcx: ty::ctxt, f = |item_id| { match tcx.items.find(&item_id) { Some(&node_item(item, _)) => item.vis != public, - Some(&node_foreign_item(_, _, vis, _)) => vis != public, + Some(&node_foreign_item(*)) => false, Some(&node_method(method, impl_did, _)) => { match method.vis { private => true, diff --git a/src/test/run-pass/pub-extern-privacy.rs b/src/test/run-pass/pub-extern-privacy.rs new file mode 100644 index 0000000000000..2927279f6a29e --- /dev/null +++ b/src/test/run-pass/pub-extern-privacy.rs @@ -0,0 +1,14 @@ +use std::cast::transmute; + +mod a { + extern { + pub fn free(x: *u8); + } +} + +fn main() { + unsafe { + a::free(transmute(0)); + } +} +