rust-lang/rust — pull request #19536 by luqmana (2014-12-04 21:08:17+00:00)
Title: Enum layout optimizations

Part 1 (First 3 commits): This extends the nullable enum opt to traverse beyond just the first level to find possible fields to use as the discriminant. So now, it'll work through structs, tuples, and fixed sized arrays.

Part 2: Introduce a new lang item, NonZero, that you can use to wrap raw pointers or integral types to indicate to rustc that the underlying value is known to never be 0/NULL. We then use this in Vec, Rc and Arc to have them also benefit from the nullable enum opt.

```
x86_64 Linux:
T Option (Before) Option (After)
Vec: 24 32 24
String: 24 32 24
Rc: 8 16 8
Arc: 8 16 8
[Box, ..2]: 16 24 16
(String, uint): 32 40 32
```