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:
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)
User
mattscodefrom 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)
It compiles, and when run it outputs:
Note that
x()is not an error and picksb::xas the preferredx. Callinga::x()is an ambiguity error, as expected.This bug exists in at least: