Skip to content

Commit 92a4717

Browse files
committed
---
yaml --- r: 166763 b: refs/heads/master c: 6d91419 h: refs/heads/master i: 166761: 04b5150 166759: 0f1ee11 v: v3
1 parent 9e01408 commit 92a4717

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5fb1e6b1e2952b1205baaa3fc9facaf7f5b34483
2+
refs/heads/master: 6d91419f27b25810f2cfcd263e0e20b62910f4ff
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 023dfb0c898d851dee6ace2f8339b73b5287136b
55
refs/heads/try: f5d619caf9f32458680fae55526b99582ca682dd

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,21 @@ fn main() {
3434
// Pointers - Box<T>
3535
assert_eq!(size_of::<Box<int>>(), size_of::<Option<Box<int>>>());
3636

37-
3837
// The optimization can't apply to raw pointers
3938
assert!(size_of::<Option<*const int>>() != size_of::<*const int>());
4039
assert!(Some(0 as *const int).is_some()); // Can't collapse None to null
4140

41+
struct Foo {
42+
_a: Box<int>
43+
}
44+
struct Bar(Box<int>);
45+
46+
// Should apply through structs
47+
assert_eq!(size_of::<Foo>(), size_of::<Option<Foo>>());
48+
assert_eq!(size_of::<Bar>(), size_of::<Option<Bar>>());
49+
// and tuples
50+
assert_eq!(size_of::<(u8, Box<int>)>(), size_of::<Option<(u8, Box<int>)>>());
51+
// and fixed-size arrays
52+
assert_eq!(size_of::<[Box<int>, ..1]>(), size_of::<Option<[Box<int>, ..1]>>());
53+
4254
}

0 commit comments

Comments
 (0)