diff options
| author | Luqman Aden <laden@csclub.uwaterloo.ca> | 2014-12-05 14:41:28 -0500 |
|---|---|---|
| committer | Luqman Aden <laden@csclub.uwaterloo.ca> | 2014-12-28 19:40:47 -0500 |
| commit | 6d91419f27b25810f2cfcd263e0e20b62910f4ff (patch) | |
| tree | 6c9e5f58985700e6707a0542a40657198b1c33fb /src/test/run-pass/enum-null-pointer-opt.rs | |
| parent | 5fb1e6b1e2952b1205baaa3fc9facaf7f5b34483 (diff) | |
| download | rust-6d91419f27b25810f2cfcd263e0e20b62910f4ff.tar.gz rust-6d91419f27b25810f2cfcd263e0e20b62910f4ff.zip | |
Add tests.
Diffstat (limited to 'src/test/run-pass/enum-null-pointer-opt.rs')
| -rw-r--r-- | src/test/run-pass/enum-null-pointer-opt.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index 2d4819231fa..afed658a27b 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -34,9 +34,21 @@ fn main() { // Pointers - Box<T> assert_eq!(size_of::<Box<int>>(), size_of::<Option<Box<int>>>()); - // The optimization can't apply to raw pointers assert!(size_of::<Option<*const int>>() != size_of::<*const int>()); assert!(Some(0 as *const int).is_some()); // Can't collapse None to null + struct Foo { + _a: Box<int> + } + struct Bar(Box<int>); + + // Should apply through structs + assert_eq!(size_of::<Foo>(), size_of::<Option<Foo>>()); + assert_eq!(size_of::<Bar>(), size_of::<Option<Bar>>()); + // and tuples + assert_eq!(size_of::<(u8, Box<int>)>(), size_of::<Option<(u8, Box<int>)>>()); + // and fixed-size arrays + assert_eq!(size_of::<[Box<int>, ..1]>(), size_of::<Option<[Box<int>, ..1]>>()); + } |
