Open
Description
Consider the code below:
enum Foo { Bar(i32) }
impl Foo {
fn Bar(x: i32) -> Foo {
println!("I'm uncallable");
Foo::Bar(x)
}
}
fn main() {
Foo::Bar(0); // Variant constructor.
<Foo>::Bar(0); // Inherent function.
}
It compiles successfully and terminates with no output. There is an ambiguity between the variant and the associated function, though it seems we always prefer the variant, making the associated function uncallable. Having an inherent associated function with the same name as a variant should be an error.
Edit: @petrochenkov points out that it's not actually uncallable, you can call it with <Foo>::Bar(0)
. A deny-by-default lint then perhaps?