Skip to content

Commit 27d539f

Browse files
committed
Add tests for NonZero.
1 parent e6a3c6e commit 27d539f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/run-pass/enum-null-pointer-opt.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111

1212
use std::mem::size_of;
13+
use std::ptr::NonZero;
14+
use std::rc::Rc;
15+
use std::sync::Arc;
1316

1417
trait Trait {}
1518

@@ -52,4 +55,16 @@ fn main() {
5255
// and fixed-size arrays
5356
assert_eq!(size_of::<[Box<int>, ..1]>(), size_of::<Option<[Box<int>, ..1]>>());
5457

58+
// Should apply to NonZero
59+
assert_eq!(size_of::<NonZero<uint>>(), size_of::<Option<NonZero<uint>>>());
60+
assert_eq!(size_of::<NonZero<*mut i8>>(), size_of::<Option<NonZero<*mut i8>>>());
61+
62+
// Should apply to types that use NonZero internally
63+
assert_eq!(size_of::<Vec<int>>(), size_of::<Option<Vec<int>>>());
64+
assert_eq!(size_of::<Arc<int>>(), size_of::<Option<Arc<int>>>());
65+
assert_eq!(size_of::<Rc<int>>(), size_of::<Option<Rc<int>>>());
66+
67+
// Should apply to types that have NonZero transitively
68+
assert_eq!(size_of::<String>(), size_of::<Option<String>>());
69+
5570
}

0 commit comments

Comments
 (0)