convert print-type-sizes to use `start` instead of `main`

This avoids bringing in unwind machinery.
This commit is contained in:
Niko Matsakis 2017-12-05 05:03:59 -05:00 committed by Bastian Köcher
parent b452c432cd
commit 19adeaa3c6
10 changed files with 47 additions and 10 deletions

View File

@ -15,7 +15,10 @@
// that one cannot control the sizes of these types with the same sort
// of enum-variant manipulation tricks.
pub fn main() {
#![feature(start)]
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _byte: u8 = 0;
let _word: usize = 0;
let _tuple: (u8, usize)= (0, 0);
@ -25,4 +28,6 @@ pub fn main() {
fn id(x: u8) -> u8 { x };
fn bye(_: u8) -> ! { loop { } }
0
}

View File

@ -15,6 +15,8 @@
// monomorphized, in the MIR of the original function in which they
// occur, to have their size reported.
#![feature(start)]
// In an ad-hoc attempt to avoid the injection of unwinding code
// (which clutters the output of `-Z print-type-sizes` with types from
// `unwind::libunwind`):
@ -66,9 +68,11 @@ pub fn f1<T:Copy>(x: T) {
Pair::new(FiftyBytes::new(), FiftyBytes::new());
}
pub fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _b: Pair<u8> = Pair::new(0, 0);
let _s: Pair<SevenBytes> = Pair::new(SevenBytes::new(), SevenBytes::new());
let _z: ZeroSized = ZeroSized;
f1::<SevenBytes>(SevenBytes::new());
0
}

View File

@ -14,6 +14,8 @@
// This file illustrates that when multiple structural types occur in
// a function, every one of them is included in the output.
#![feature(start)]
pub struct SevenBytes([u8; 7]);
pub struct FiftyBytes([u8; 50]);
@ -22,8 +24,10 @@ pub enum Enum {
Large(FiftyBytes),
}
pub fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _e: Enum;
let _f: FiftyBytes;
let _s: SevenBytes;
0
}

View File

@ -21,6 +21,7 @@
// aligned (while on most it is 8-byte aligned) and so the resulting
// padding and overall computed sizes can be quite different.
#![feature(start)]
#![feature(nonzero)]
#![allow(dead_code)]
@ -76,7 +77,8 @@ pub enum Enum4<A, B, C, D> {
Four(D)
}
pub fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _x: MyOption<NonZero<u32>> = Default::default();
let _y: EmbeddedDiscr = Default::default();
let _z: MyOption<IndirectNonZero<u32>> = Default::default();
@ -87,4 +89,5 @@ pub fn main() {
let _e: Enum4<(), char, (), ()> = Enum4::One(());
let _f: Enum4<(), (), bool, ()> = Enum4::One(());
let _g: Enum4<(), (), (), MyOption<u8>> = Enum4::One(());
0
}

View File

@ -15,12 +15,16 @@
// (even if multiple functions), it is only printed once in the
// print-type-sizes output.
#![feature(start)]
pub struct SevenBytes([u8; 7]);
pub fn f1() {
let _s: SevenBytes = SevenBytes([0; 7]);
}
pub fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _s: SevenBytes = SevenBytes([0; 7]);
0
}

View File

@ -20,6 +20,7 @@
// padding and overall computed sizes can be quite different.
#![allow(dead_code)]
#![feature(start)]
#[derive(Default)]
#[repr(packed)]
@ -42,7 +43,9 @@ struct Padded {
d: u8,
}
pub fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _c: Packed = Default::default();
let _d: Padded = Default::default();
0
}

View File

@ -19,6 +19,7 @@
// aligned (while on most it is 8-byte aligned) and so the resulting
// padding and overall computed sizes can be quite different.
#![feature(start)]
#![allow(dead_code)]
struct S {
@ -37,4 +38,7 @@ enum E2 {
B(S),
}
fn main() { }
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
0
}

View File

@ -20,6 +20,7 @@
// padding and overall computed sizes can be quite different.
#![feature(attr_literals)]
#![feature(repr_align)]
#![feature(start)]
#![allow(dead_code)]
#[repr(align(16))]
@ -39,6 +40,8 @@ struct S {
d: i8,
}
fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _s: S = Default::default();
0
}

View File

@ -12,8 +12,11 @@
// must-compile-successfully
#![feature(never_type)]
#![feature(start)]
pub fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _x: Option<!> = None;
let _y: Result<u32, !> = Ok(42);
0
}

View File

@ -19,6 +19,8 @@
// 2. For an enum, the print-type-sizes output will also include the
// size of each variant.
#![feature(start)]
pub struct SevenBytes([u8; 7]);
pub struct FiftyBytes([u8; 50]);
@ -27,6 +29,8 @@ pub enum Enum {
Large(FiftyBytes),
}
pub fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _e: Enum;
0
}