Skip to content

use <module>::* imports non-public module members #4366

Closed
@vadimcn

Description

@vadimcn

This code fails to compile (unless foo is declared as "pub fn foo()..."):

mod m1 {
    fn foo() {}
}
use m1::foo;
>rustc test.rs
test.rs:4:4: 4:12 error: failed to resolve import
test.rs:4 use m1::foo;
              ^~~~~~~~

This one, however, succeeds:

mod m1 {
    fn foo() {}
}
use m1::*;

fn main()
{
    foo();
}

It is a bit surprising to me that wildcard import pulls in all module members, including non-publics, whereas named import doesn't. I wonder if this is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesA-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions