Skip to content

Commit e83272b

Browse files
committed
Add tests for NonZero.
1 parent 466135b commit e83272b

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

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

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

0 commit comments

Comments
 (0)