2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
|
|
|
|
2018-09-14 10:20:28 +00:00
|
|
|
#![allow(dead_code)]
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2013-10-17 01:34:01 +00:00
|
|
|
use std::mem;
|
2013-05-25 02:35:29 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
enum E<T> { Thing(isize, T), Nothing((), ((), ()), [i8; 0]) }
|
|
|
|
struct S<T>(isize, T);
|
2013-04-22 15:49:21 +00:00
|
|
|
|
|
|
|
// These are macros so we get useful assert messages.
|
|
|
|
|
|
|
|
macro_rules! check_option {
|
|
|
|
($T:ty) => {
|
2013-10-17 01:34:01 +00:00
|
|
|
assert_eq!(mem::size_of::<Option<$T>>(), mem::size_of::<$T>());
|
2013-04-22 15:49:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! check_fancy {
|
|
|
|
($T:ty) => {
|
2013-10-17 01:34:01 +00:00
|
|
|
assert_eq!(mem::size_of::<E<$T>>(), mem::size_of::<S<$T>>());
|
2013-04-22 15:49:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! check_type {
|
|
|
|
($T:ty) => {{
|
|
|
|
check_option!($T);
|
|
|
|
check_fancy!($T);
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2015-03-26 00:06:52 +00:00
|
|
|
check_type!(&'static isize);
|
|
|
|
check_type!(Box<isize>);
|
2020-09-01 21:28:11 +00:00
|
|
|
check_type!(extern "C" fn());
|
2013-04-22 15:49:21 +00:00
|
|
|
}
|