Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign function visible outside of crate. #16725

Closed
vasac opened this issue Aug 24, 2014 · 1 comment · Fixed by #16740
Closed

Foreign function visible outside of crate. #16725

vasac opened this issue Aug 24, 2014 · 1 comment · Fixed by #16740
Labels
A-visibility Area: Visibility / privacy.

Comments

@vasac
Copy link

vasac commented Aug 24, 2014

// lib.rs
#![crate_name="foo"]
#![crate_type="lib"]

extern {
    fn bar();
}

pub fn visible() {
}

fn invisible() {
}
// example.rs
extern crate foo;

fn main() {
    foo::visible();
    foo::bar(); // visible
//  foo::invisible();
}

$ rustc --version
rustc 0.12.0-pre-nightly (75396b2 2014-08-22 23:55:50 +0000)

@alexcrichton
Copy link
Member

Nominating, seems bad!

alexcrichton added a commit to alexcrichton/rust that referenced this issue Aug 25, 2014
alexcrichton added a commit to alexcrichton/rust that referenced this issue Aug 25, 2014
The privacy pass of the compiler was previously not taking into account the
privacy of foreign items, or bindings to external functions. This commit fixes
this oversight by encoding the visibility of foreign items into the metadata for
each crate.

Any code relying on this will start to fail to  compile and the bindings must be
marked with `pub` to indicate that they can be used externally.

Closes rust-lang#16725
[breaking-change]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-visibility Area: Visibility / privacy.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants