Skip to content

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

@jseyfried

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions