-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Should types that contain zero-length vectors of themselves be allowed? #11924
Copy link
Copy link
Open
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).A-arrayArea: `[T; N]`Area: `[T; N]`A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).A-arrayArea: `[T; N]`Area: `[T; N]`A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In the discussion of pull request #11839, which aims to check the representability of structs and enums properly in
typeck, @huonw pointed out that the semantics for types that directly contain zero-length vectors of themselves are potentially still undecided.Consider for example (play):
If
typeckallowsenum Foo { A([Foo; 0]) }orstruct Bar { x: [Bar; 0] }then there is an infinite recursion + stack overflow intrans::adt::represent_type, so I will amend #11839 to disallow these cases and add a FIXME referencing this issue.To me, it seems more consistent to allow any zero-length vector than to allow only some, but the only use case I can think of is that it may make some macros simpler to write.