Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glob imports ignore private items of parent modules #22145

Closed
crumblingstatue opened this issue Feb 10, 2015 · 1 comment
Closed

Glob imports ignore private items of parent modules #22145

crumblingstatue opened this issue Feb 10, 2015 · 1 comment

Comments

@crumblingstatue
Copy link
Contributor

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;
                             ^~~~~~~
@alexcrichton
Copy link
Member

This is actually working as intended. A glob import will only import public items from another module, it will unconditionally ignore all private items. You may be interested in opening an issue in the RFC tracker to track a tweak to this behavior if you'd like to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants