Skip to content

Can reach private modules through public modules from outside the crate #7388

Closed
@SiegeLord

Description

@SiegeLord

rustc version:

rustc 0.6 (dc4560d 2013-06-21 19:19:58 -0700)
host: x86_64-unknown-linux-gnu

Given two crates, crate1.rs and crate2.rs, I can access a private module within crate2.rs through a public module.

crate1.rs:

extern mod crate2;

fn main()
{
    crate2::public::private::foo(); // Works but shouldn't
    // crate2::private::foo(); // Correctly gives the error
} 

crate2.rs:

#[crate_type = "lib"];

pub mod public
{
    mod private
    {
        pub fn foo() { }
    }
}

mod private
{
    pub fn foo() { }
}

fn bar()
{
    // Both of these work since they are intra-crate
    public::private::foo();
    private::foo();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions