Skip to content

Commit 5ef11d9

Browse files
committed
note on uninhabited structs
1 parent 49f3c12 commit 5ef11d9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

reference/src/layout/structs-and-tuples.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ themselves is already entirely determined by their types, and since we intend to
7979
allow creating references to fields (`&s.f1`), structs do not have any
8080
wiggle-room there.
8181

82+
**Note:** This is only true if the struct is inhabited. For structs like `(i32,
83+
!)` that do not have a valid inhabitant, the compiler has more freedom. After
84+
all, no references to fields can ever be taken. For example, such structs might
85+
be zero-sized.
86+
8287
This can be visualized as follows:
8388
```text
8489
[ <--> [field 3] <-----> [field 1] <-> [ field 2 ] <--> ]

0 commit comments

Comments
 (0)