Skip to content

A private module can be used outside its containing module #31779

Description

@jseyfried

Consider the following code:

mod foo {
    mod bar { // `bar` should only be visible inside `foo`
        pub struct S;
    }
    pub use self::bar::S;
}

impl foo::S {
    fn f() {}
    pub fn g() {}
}

fn main() {
    foo::bar::S::f(); //< yet this line compiles
    // foo::bar::S::g(); //< this line would give the correct privacy error
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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