Skip to content

Non-modules allowed in module positions in use. #38293

Closed
@SergioBenitez

Description

@SergioBenitez

Consider the following piece of code, which compiles:

mod bar {
    pub fn foo() { }
}

use bar::foo::{self};

fn main() {
    foo();
}

The use declaration is allowed to use foo as a module when foo is actually a function. This should not be allowed.

Further, when foo does exist as a module, regardless of visibility, self incorrectly imports items with the same name in that module:

mod bar {
    mod foo { }
    pub fn foo() { }
}

use bar::foo::{self};

fn main() {
    foo();
}

Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions