]> git.lizzy.rs Git - rust.git/commitdiff
Add tests.
authorLuqman Aden <laden@csclub.uwaterloo.ca>
Fri, 5 Dec 2014 19:41:28 +0000 (14:41 -0500)
committerLuqman Aden <laden@csclub.uwaterloo.ca>
Mon, 29 Dec 2014 00:40:47 +0000 (19:40 -0500)
src/test/run-pass/enum-null-pointer-opt.rs

index 2d4819231fad0a9fb7d1be6e065446e4bcff64a6..afed658a27b016f60daca51e9e27d93216f535e9 100644 (file)
@@ -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]>>());
+
 }