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

visible_private_types lint sometimes should explain why type is private #13422

Closed
pnkfelix opened this issue Apr 9, 2014 · 1 comment
Closed
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Apr 9, 2014

Here is some code:

#![crate_type="lib"]

pub mod hello {
    pub use self::inner::foo;

    mod inner {
        pub fn foo() -> Bar { Bar }

        pub struct Bar;
    }
}

when I try to compile it, I get:

% rustc /tmp/p.rsb_
/tmp/p.rs:7:25: 7:28 warning: private type in exported type signature, #[warn(visible_private_types)] on by default
/tmp/p.rs:7         pub fn foo() -> Bar { Bar }
                                    ^~~

Now, maybe in the above code the problem is obvious, but in the original context where this arose, the inner was in a separate file from hello, and I did a lot of head scratching, saying "but I said pub struct Bar..."

I think that if the lint is complaining about a type that is itself declared public, then the lint should have a note indicating at least one module along the chain that is private. And maybe a note saying "you can fix this by either doing pub use self::inner::Bar or by making the mod inner public."

@reem
Copy link
Contributor

reem commented Dec 1, 2014

Triage: it appears that our privacy-tracking has become a lot more simplistic, since this no longer errors at all. Nominating for close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

4 participants