Skip to content

visible_private_types warning when compiling with with test #15912

Closed
@mvdnes

Description

@mvdnes

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
                            ^~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions