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