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

Ambiguous name after glob import is not an error #47525

Closed
bluss opened this issue Jan 17, 2018 · 1 comment · Fixed by #113099
Closed

Ambiguous name after glob import is not an error #47525

bluss opened this issue Jan 17, 2018 · 1 comment · Fixed by #113099
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bluss
Copy link
Member

bluss commented Jan 17, 2018

User mattscode from irc reported that the following code compiles, and seems to pick a favourite between identical names. We agree we expect this to be a compile error:

(playground link)

fn main() {
    use a::*;
    x();
    // a::x(); // This fails to compile due to an ambiguous x
}

mod a {
    mod b {
        pub fn x() { println!(module_path!()); }
    }
    mod c {
        pub fn x() { println!(module_path!()); }
    }
    
    pub use self::b::*;
    pub use self::c::*;
}

It compiles, and when run it outputs:

playground::a::b

Note that x() is not an error and picks b::x as the preferred x. Calling a::x() is an ambiguity error, as expected.

This bug exists in at least:

  • rustc 1.23.0
  • rustc 1.25.0-nightly (da569fa 2018-01-16)
@bluss
Copy link
Member Author

bluss commented Jan 17, 2018

Relevant RFC: Changes to name resolution rust-lang/rfcs/pull/1560

@petrochenkov petrochenkov added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Jan 17, 2018
@XAMPPRocky XAMPPRocky added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 23, 2018
@apiraino apiraino added P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. C-bug Category: This is a bug. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jun 27, 2022
@bors bors closed this as completed in 2dc6610 Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants