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

Private type exposed in public without a warning #73410

Closed
kvark opened this issue Jun 16, 2020 · 3 comments
Closed

Private type exposed in public without a warning #73410

kvark opened this issue Jun 16, 2020 · 3 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kvark
Copy link
Contributor

kvark commented Jun 16, 2020

Here is the code:

pub mod foo {
    mod sub {
        pub struct Bar;
    }
    
    use sub::Bar;
    
    pub struct Foo {
        pub bar: Bar,
    }
}

//use foo::Bar; // this errors for `Bar` being private

I expected to see this happen (compile error):

Private type sub::Bar exposed in public signature of Foo::bar

Instead, this happened: compiles just fine.
Trying to use the type fails, since it's private

Meta

Tested on stable 1.44.0 and nightly of 1.46.0

playground link

@kvark kvark added the C-bug Category: This is a bug. label Jun 16, 2020
@cuviper
Copy link
Member

cuviper commented Jun 16, 2020

Sometimes this is done intentionally, like the Sealed trait here:
https://rust-lang.github.io/api-guidelines/future-proofing.html

@Alexendoo Alexendoo added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Jun 17, 2020
@Dylan-DPC
Copy link
Member

Closing this as it is intended and not sure if there's anything that can be done here

@Dylan-DPC Dylan-DPC closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2023
@petrochenkov
Copy link
Contributor

This is now addressed by a lint called unnameable_types (#48054), but that lint is allowed by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants