Skip to content

visible_private_types warning when compiling with with test #15912

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
mvdnes opened this issue Jul 23, 2014 · 2 comments · Fixed by #16034
Closed

visible_private_types warning when compiling with with test #15912

mvdnes opened this issue Jul 23, 2014 · 2 comments · Fixed by #16034
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@mvdnes
Copy link
Contributor

mvdnes commented Jul 23, 2014

Description

Possibly due to #15847, I am experiencing a visible_private_types warning when compiling with --test. The code normally would not expose the private types. An example can be seen below.

Versions

PS C:\Users\mvdnes\Desktop> systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 8.1 Pro with Media Center
OS Version:                6.3.9600 N/A Build 9600

PS C:\Users\mvdnes\Desktop> rustc -v
rustc 0.12.0-pre-nightly (aa0e35bc6 2014-07-22 00:26:21 +0000)

Example code

The following code gives no warnings when compiled normally, but does give the warning when compiled with --test.

Note that Bar should is not exported since foo is not public.

#![crate_type = "lib" ]
#![allow(dead_code)]

mod bar {
    pub struct Bar;
}

mod foo {
    pub struct Foo {
        pub bar: ::bar::Bar
    }

    #[cfg(test)]
    mod test {
        #[test]
        fn testfoo() {}
    }
}

Output

PS C:\Users\mvdnes\Desktop> rustc .\test.rs

PS C:\Users\mvdnes\Desktop> rustc .\test.rs --test
test.rs:10:18: 10:28 warning: private type in exported type signature, #[warn(visible_private_types)] on by default
test.rs:10         pub bar: ::bar::Bar
                            ^~~~~~~~~~
@huonw huonw added the A-lint label Jul 23, 2014
@huonw
Copy link
Member

huonw commented Jul 23, 2014

Seems like fall-out of #15847. cc @sfackler

@sfackler
Copy link
Member

Yeah, I think we should tweak the test harness expansion to reexport just the submodule's reexport module instead of the entire submodule:

pub mod __test_reexports {
    pub use foo__test_reexports = super::foo::test_reexports;
}

sfackler added a commit to sfackler/rust that referenced this issue Jul 27, 2014
We previously reexported entire modules, which caused private things to
become reachable and trip the dead code and private items in public API
lints.

Closes rust-lang#15912
bors added a commit that referenced this issue Jul 29, 2014
We previously reexported entire modules, which caused private things to
become reachable and trip the dead code and private items in public API
lints.

Closes #15912
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 4, 2023
chore: remove unused `PhantomData`

This PR removes an unused `PhantomData` in `FileItemTreeId`.

*Note:* I am not sure how this should be implemented, maybe as a type instead of a wrapper struct? I'd be happy to do so if needed 👍
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

Successfully merging a pull request may close this issue.

3 participants