Skip to content

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

Closed
@SergioBenitez

Description

@SergioBenitez
Contributor

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();
}

Activity

self-assigned this
on Dec 11, 2016
jseyfried

jseyfried commented on Dec 11, 2016

@jseyfried
Contributor
added
A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
on Dec 11, 2016
jseyfried

jseyfried commented on Dec 12, 2016

@jseyfried
Contributor

Fixed in #38313.

added a commit that references this issue on Jan 11, 2017

Auto merge of #38313 - jseyfried:self_imports, r=nrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @SergioBenitez@jseyfried

      Issue actions

        Non-modules allowed in module positions in `use`. · Issue #38293 · rust-lang/rust