]> git.lizzy.rs Git - rust.git/commit
auto merge of #19765 : luqmana/rust/nonzero-lang-item, r=nikomatsakis
authorbors <bors@rust-lang.org>
Mon, 29 Dec 2014 08:06:20 +0000 (08:06 +0000)
committerbors <bors@rust-lang.org>
Mon, 29 Dec 2014 08:06:20 +0000 (08:06 +0000)
commit25fb12b8a5411901675ede6b147bbc6c0b7437b7
tree782cd6a61471a7939220ce7e9aae7cdb14536159
parent03a1188cf35b3765d8eb718d3b757c5a5d7e9497
parent766a71922fcabb8e0885b372d116c07149b6bb07
auto merge of #19765 : luqmana/rust/nonzero-lang-item, r=nikomatsakis

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. This also introduces 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.

As per https://github.com/rust-lang/rfcs/pull/499 NonZero is not exposed via the `libstd` facade.

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

Fixes #19419.
Fixes #13194.
Fixes #9378.
Fixes #7576.