-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-unnamed_fields`#![feature(unnamed_fields)]``#![feature(unnamed_fields)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.This issue requires the use of incomplete features.
Description
Example:
enum E {
_,
_ = 1,
_(),
_ {},
}
I don't think this is intended; unnamed fields are described for struct
and union
, but not for enum
.
A built-in derived trait implementation appears to work as long as only a single unnamed variant exists, but more than one unnamed variant usually (but not always) results in errors (e.g. non-exhaustive patterns or attempting to use the wrong kind of variant).
These should probably just be forbidden. There's probably no harm in allowing the syntax, but semantically unnamed variants don't make any real sense. Maybe they could in an “inline the variants” manner, but that very much isn't the currently observed behavior.
Meta
rustc 1.83.0-nightly (2024-09-12 adaff53)
@rustbot label: +F-unnamed-fields +requires-incomplete-features
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-unnamed_fields`#![feature(unnamed_fields)]``#![feature(unnamed_fields)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.This issue requires the use of incomplete features.