-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Closed
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-langRelevant to the language teamRelevant to the language team
Description
The following code works:
enum Enum {
Variant {}
}
impl Enum {
const Variant: Enum = Enum::Variant {};
}
However, accessing the associated constant does not:
let _ = Enum::Variant;
// error[E0423]: expected value, found struct variant `Enum::Variant`
Explanation why I think this should work
Most items are in one of three namespaces/universes: The type namespace, the value namespace, and the macro namespace. For example, regular structs are in the type namespace, whereas constants are in the value namespace, so a struct and a constant can share the same name (this is also how unit structs are desugared):
struct S {}
const S: S = S {};
let _: S = S;
I expected the same to work for enum variants as well.
If you don't intend to fix this, please consider changing the error message, as the phrase "struct variant" can be misleading.
Meta
It can be reproduced on stable, beta and nightly. See playground.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-langRelevant to the language teamRelevant to the language team