Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Closed
SergioBenitez opened this issue Dec 11, 2016 · 2 comments
Closed

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

SergioBenitez opened this issue Dec 11, 2016 · 2 comments
Assignees
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@SergioBenitez
Copy link
Contributor

SergioBenitez commented Dec 11, 2016

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();
}
@jseyfried jseyfried self-assigned this Dec 11, 2016
@jseyfried
Copy link
Contributor

cc @petrochenkov

@jseyfried jseyfried added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Dec 11, 2016
@jseyfried
Copy link
Contributor

Fixed in #38313.

bors added a commit that referenced this issue Jan 11, 2017
resolve: clean up the semantics of `self` in an import list

Change `self` in an import list `use foo::bar::{self, ...};` to import `bar` only in the type namespace. Today, `bar` is imported in every namespace in which `foo::bar` is defined.

This is a [breaking-change], see #38293 (comment) for examples of code that would break.

Fixes #38293.
r? @nrc
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

No branches or pull requests

2 participants