Destructuring tuple structs with public leading fields and private trailing fields by tuple syntax is disallowed #139972
Labels
C-bug
Category: This is a bug.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
Minimal reproducible example
Current behavior
Expected behvaior
This should be allowed to compile, since it is unambiguous that the first element of the tuple struct is a public field, regardless of the number of subsequent fields. The tuple struct destructuring syntax
implies the exact same conditions as the following pattern:
Both of them imply:
foo::Bar
MUST be a tuple structfoo::Bar
MUST have a visible field.0
foo::Bar
MAY have non-exhaustive fields after.0
, which we do not need to accessHowever, the
foo:: Bar {0: i, ..}
case compiles, whilefoo::Bar(i, ..)
does not.Proposed fix
If the first 3 fields of a tuple struct are visible, users should be allowed to match a value of the tuple struct by
Path(_, ..)
,Path(_, _, ..)
orPath(_, _, _, ..)
, where_
are placeholders for arbitrary patterns.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: