1 // compile-flags: -Z print-type-sizes --crate-type=lib
4 // ^-- needed because `--pass check` does not emit the output needed.
5 // FIXME: consider using an attribute instead of side-effects.
7 // This file illustrates how generics are handled: types have to be
8 // monomorphized, in the MIR of the original function in which they
9 // occur, to have their size reported.
11 #[derive(Copy, Clone)]
18 fn new(a: T, d: T) -> Self {
26 #[derive(Copy, Clone)]
27 pub struct SevenBytes([u8; 7]);
28 pub struct FiftyBytes([u8; 50]);
33 fn new() -> Self { SevenBytes([0; 7]) }
37 fn new() -> Self { FiftyBytes([0; 50]) }
40 pub fn f1<T:Copy>(x: T) {
41 let _v: Pair<T> = Pair::new(x, x);
42 let _v2: Pair<FiftyBytes> =
43 Pair::new(FiftyBytes::new(), FiftyBytes::new());
47 let _b: Pair<u8> = Pair::new(0, 0);
48 let _s: Pair<SevenBytes> = Pair::new(SevenBytes::new(), SevenBytes::new());
49 let ref _z: ZeroSized = ZeroSized;
50 f1::<SevenBytes>(SevenBytes::new());