Skip to content

Commit 48ca0bf

Browse files
committed
Address stylistic review comments
1 parent 0b100f1 commit 48ca0bf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/const-eval.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ allows us to represent arrays, many structs, tuples, enums and most primitives.
4343
being permitted in the type system is that every value must be uniquely represented. In other words:
4444
a specific value must only be representable in one specific way. For example: there is only one way
4545
to represent an array of two integers as a `ValTree`: `ValTree::Branch(&[ValTree::Leaf(first_int), ValTree;:Leaf(second_int)])`.
46-
Even though theoretically a `[u32; 2]` could be encoded in a `u64` and thus just be a `ValTree::Leaf(bits_of_two_u32)`, that
46+
Even though theoretically a `[u32; 2]` could be encoded in a `u64` and thus just be a `ValTree::Leaf(bits_of_two_u32)`, that
4747
is not a legal construction of `ValTree` (and is so complex to do, so it is unlikely anyone is tempted to do so).
48+
4849
These rules also mean that some values are not representable. There can be no `union`s in type level
4950
constants, as it is not clear how they should be represented, because their active variant is unknown.
5051
Similarly there is no way to represent pointers, as addresses are unknown at compile-time and thus we
5152
cannot make any assumptions about them. References on the other hand can be represented, as equality
5253
for references is defined as equality on their value, so we ignore their address and just look at the
5354
backing value. This means that there is no difference in encoding for `&42` and `42`.
55+
5456
As a consequence, all decoding of `ValTree` must happen by matching on the type first and making decisions
5557
depending on that. The value itself gives no useful information without the type that belongs to it.
5658
One notable oddity is `&str` representation. There is no sized equivalent of it, so unlike slices we cannot

0 commit comments

Comments
 (0)