diff options
| author | Austin Hicks <camlorn@camlorn.net> | 2016-12-07 12:42:07 -0500 |
|---|---|---|
| committer | Austin Hicks <camlorn@camlorn.net> | 2016-12-14 12:28:26 -0500 |
| commit | 79c35bbd8cbab76e0ba2e51970e2fc2c35cdcc45 (patch) | |
| tree | a1a5ed6884afc1f9dc5ea87cd13cd15934710ef5 /src | |
| parent | 9966bbd1b11fcd2866cdbd21146f5e9a0d8ea66c (diff) | |
| download | rust-79c35bbd8cbab76e0ba2e51970e2fc2c35cdcc45.tar.gz rust-79c35bbd8cbab76e0ba2e51970e2fc2c35cdcc45.zip | |
Add a case to type-sizes to explicitly verify that field reordering triggers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/run-pass/type-sizes.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs index bbb01eaaf46..6614a76107f 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -31,6 +31,10 @@ enum e3 { a([u16; 0], u8), b } +// Test struct field reordering to make sure it actually reorders. +struct WillOptimize1(u8, u16, u8); +struct WillOptimize2 { a: u8, b: u16, c: u8} + pub fn main() { assert_eq!(size_of::<u8>(), 1 as usize); assert_eq!(size_of::<u32>(), 4 as usize); @@ -54,4 +58,7 @@ pub fn main() { assert_eq!(size_of::<e1>(), 8 as usize); assert_eq!(size_of::<e2>(), 8 as usize); assert_eq!(size_of::<e3>(), 4 as usize); + + assert_eq!(size_of::<WillOptimize1>(), 4); + assert_eq!(size_of::<WillOptimize2>(), 4); } |
