Skip to content

"error: private type in public interface" in private module #30905

Closed
@SimonSapin

Description

@SimonSapin

Reduced test case:

struct HostInternal;

mod parser {
    use super::HostInternal;
    pub fn parse() -> HostInternal {
        unimplemented!();
    }
}

Output with rustc 1.7.0-nightly (1447ce7 2016-01-13)

a.rs:5:23: 5:35 error: private type in public interface [E0446]
a.rs:5     pub fn parse() -> HostInternal {
                             ^~~~~~~~~~~~
a.rs:5:23: 5:35 help: run `rustc --explain E0446` to see a detailed explanation
error: aborting due to previous error

This is incorrect: the parse function is not visible anywhere HostInternal isn’t since the parser module is not public.

In my non-reduced crate I get a warning rather than an error but I haven’t managed to reproduce that in the reduced case. (Regardless, that warning is also incorrect.)

src/parser.rs:520:43: 520:55 warning: private type in public interface (error E0446), #[warn(private_in_public)] on by default
src/parser.rs:520                           -> ParseResult<(HostInternal, &'i str)> {
                                                            ^~~~~~~~~~~~
src/parser.rs:520:43: 520:55 note: this lint will become a HARD ERROR in a future release!
src/parser.rs:520                           -> ParseResult<(HostInternal, &'i str)> {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions