Closed
Description
enum Enum { Variant }
impl Enum {
fn misspellable() {}
}
trait Trait {
fn misspellable_trait() {}
}
impl Trait for Enum {
fn misspellable_trait() {}
}
fn main() {
Enum::mispellable();
Enum::mispellable_trait();
}
Produces the error messages
error[E0599]: no variant named `mispellable` found for type `Enum` in the current scope
--> src/main.rs:16:5
|
1 | enum Enum { Variant }
| --------- variant `mispellable` not found here
...
16 | Enum::mispellable();
| ^^^^^^^^^^^^^^^^^ variant not found in `Enum`
|
= help: did you mean `misspellable`?
error[E0599]: no variant named `mispellable_trait` found for type `Enum` in the current scope
--> src/main.rs:17:5
|
1 | enum Enum { Variant }
| --------- variant `mispellable_trait` not found here
...
17 | Enum::mispellable_trait();
| ^^^^^^^^^^^^^^^^^^^^^^^ variant not found in `Enum`
error: aborting due to 2 previous errors
I would expect the message to read "variant or associated item" instead of just "variant". The current message is confusing; it could lead users to believe the compiler is expecting to see a variant, and would not allow functions, in the context where the error occurred (note that no spelling suggestion is given if the item is from a trait, furthering the confusion).