Skip to content

Glob imports ignore private items of parent modules #22145

@crumblingstatue

Description

@crumblingstatue

This shouldn't be the case, as child modules have access to the private items of parent modules.

Example:

pub mod foo {
    struct FooItem;
    pub mod bar {
        // use foo::FooItem; // Direct import works for both public/private
        use foo::*; // Only works if `foo::FooItem` is public
        pub fn bar_fn() {
            let _ = FooItem;
        }
    }
}

fn main() {
    foo::bar::bar_fn();
}

This gives the error:

<anon>:7:21: 7:28 error: unresolved name `FooItem`
<anon>:7             let _ = FooItem;
                             ^~~~~~~

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