Open
Description
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):
struct Foo {
recur: [Foo; 0],
}
fn main() { }
If typeck
allows enum Foo { A([Foo; 0]) }
or
struct Bar { x: [Bar; 0] }
then there is an infinite recursion + stack overflow in trans::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.