Skip to content

Private types publicly accessible. #38844

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

Closed
XAMPPRocky opened this issue Jan 5, 2017 · 4 comments
Closed

Private types publicly accessible. #38844

XAMPPRocky opened this issue Jan 5, 2017 · 4 comments

Comments

@XAMPPRocky
Copy link
Member

XAMPPRocky commented Jan 5, 2017

This may be some misunderstanding on my part, but this seems like a bug. If a private type is exposed through a public field in a struct, rustc will not error. The below example will compile as a lib.

Minimal Workable Example

use foo::Bar;

mod foo {
    pub enum Bar {
        Baz
    }
}

pub struct BarContainer(pub Bar);
pub struct FooBarContainer {
    pub inner: Bar,
}

Rust version

rustc 1.14.0 (e8a012324 2016-12-16)
binary: rustc
commit-hash: e8a0123241f0d397d39cd18fcc4e5e7edde22730
commit-date: 2016-12-16
host: x86_64-apple-darwin
release: 1.14.0
LLVM version: 3.9
@durka
Copy link
Contributor

durka commented Jan 5, 2017

What's the problem? Bar is indeed pub.

@XAMPPRocky
Copy link
Member Author

@durka But foo is not. I only noticed this when I released ddg it had a struct which contains types that have no documentation or links, this may be more of an error with rustdoc than rustc, also those types were ignored for a compiler flag #[deny(missing_docs)] until I made the mod public, which would also imply that the types are private.

@durka
Copy link
Contributor

durka commented Jan 5, 2017

As I understand it, pub means the item is public to the world -- but that doesn't mean it's accessible. It's only accessible if the chain of modules containing it is all pub. Accessibility can be controlled with re-exports. Publicity can be controlled in a more fine-grained way with pub(restricted) (still unstable).

@petrochenkov
Copy link
Contributor

This is the intended behavior, see #34537 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants