Cannot access associated constant with the same name as an enum variant if the enum's fields are unnamed #118555
Labels
A-resolve
Area: Name/path resolution done by `rustc_resolve` specifically
C-bug
Category: This is a bug.
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
I tried this code:
I expected that there would be no errors because the associated constants would be accessed. Instead,
I believe this error occurs because
VariantA
is normally constructed withVariantA {...}
, whileVariantB
andVariantC
are constructed without requiring the curly braces{}
or naming any fields.I think accessing the associated constants with the same names as
VariantB
andVariantC
should be allowed because they're all enum variants, which means they should share the same behaviour.This issue is somewhat related to #75724 , but that issue only focused on
VariantA
-type variants with named fieldsMeta
rustc --version --verbose
:I also tested this in the playground on stable, beta and nightly. This issue is present in all 3 versions.
backtrace
The text was updated successfully, but these errors were encountered: