Skip to content

Ambiguous name after glob import is not an error #47525

Closed
@bluss

Description

@bluss

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions