Skip to content

Commit 19adeaa

Browse files
nikomatsakisbkchr
authored andcommitted
convert print-type-sizes to use start instead of main
This avoids bringing in unwind machinery.
1 parent b452c43 commit 19adeaa

File tree

10 files changed

+47
-10
lines changed

10 files changed

+47
-10
lines changed

src/test/ui/print_type_sizes/anonymous.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
// that one cannot control the sizes of these types with the same sort
1616
// of enum-variant manipulation tricks.
1717

18-
pub fn main() {
18+
#![feature(start)]
19+
20+
#[start]
21+
fn start(_: isize, _: *const *const u8) -> isize {
1922
let _byte: u8 = 0;
2023
let _word: usize = 0;
2124
let _tuple: (u8, usize)= (0, 0);
@@ -25,4 +28,6 @@ pub fn main() {
2528

2629
fn id(x: u8) -> u8 { x };
2730
fn bye(_: u8) -> ! { loop { } }
31+
32+
0
2833
}

src/test/ui/print_type_sizes/generics.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// monomorphized, in the MIR of the original function in which they
1616
// occur, to have their size reported.
1717

18+
#![feature(start)]
19+
1820
// In an ad-hoc attempt to avoid the injection of unwinding code
1921
// (which clutters the output of `-Z print-type-sizes` with types from
2022
// `unwind::libunwind`):
@@ -66,9 +68,11 @@ pub fn f1<T:Copy>(x: T) {
6668
Pair::new(FiftyBytes::new(), FiftyBytes::new());
6769
}
6870

69-
pub fn main() {
71+
#[start]
72+
fn start(_: isize, _: *const *const u8) -> isize {
7073
let _b: Pair<u8> = Pair::new(0, 0);
7174
let _s: Pair<SevenBytes> = Pair::new(SevenBytes::new(), SevenBytes::new());
7275
let _z: ZeroSized = ZeroSized;
7376
f1::<SevenBytes>(SevenBytes::new());
77+
0
7478
}

src/test/ui/print_type_sizes/multiple_types.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// This file illustrates that when multiple structural types occur in
1515
// a function, every one of them is included in the output.
1616

17+
#![feature(start)]
18+
1719
pub struct SevenBytes([u8; 7]);
1820
pub struct FiftyBytes([u8; 50]);
1921

@@ -22,8 +24,10 @@ pub enum Enum {
2224
Large(FiftyBytes),
2325
}
2426

25-
pub fn main() {
27+
#[start]
28+
fn start(_: isize, _: *const *const u8) -> isize {
2629
let _e: Enum;
2730
let _f: FiftyBytes;
2831
let _s: SevenBytes;
32+
0
2933
}

src/test/ui/print_type_sizes/niche-filling.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// aligned (while on most it is 8-byte aligned) and so the resulting
2222
// padding and overall computed sizes can be quite different.
2323

24+
#![feature(start)]
2425
#![feature(nonzero)]
2526
#![allow(dead_code)]
2627

@@ -76,7 +77,8 @@ pub enum Enum4<A, B, C, D> {
7677
Four(D)
7778
}
7879

79-
pub fn main() {
80+
#[start]
81+
fn start(_: isize, _: *const *const u8) -> isize {
8082
let _x: MyOption<NonZero<u32>> = Default::default();
8183
let _y: EmbeddedDiscr = Default::default();
8284
let _z: MyOption<IndirectNonZero<u32>> = Default::default();
@@ -87,4 +89,5 @@ pub fn main() {
8789
let _e: Enum4<(), char, (), ()> = Enum4::One(());
8890
let _f: Enum4<(), (), bool, ()> = Enum4::One(());
8991
let _g: Enum4<(), (), (), MyOption<u8>> = Enum4::One(());
92+
0
9093
}

src/test/ui/print_type_sizes/no_duplicates.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
// (even if multiple functions), it is only printed once in the
1616
// print-type-sizes output.
1717

18+
#![feature(start)]
19+
1820
pub struct SevenBytes([u8; 7]);
1921

2022
pub fn f1() {
2123
let _s: SevenBytes = SevenBytes([0; 7]);
2224
}
2325

24-
pub fn main() {
26+
#[start]
27+
fn start(_: isize, _: *const *const u8) -> isize {
2528
let _s: SevenBytes = SevenBytes([0; 7]);
29+
0
2630
}

src/test/ui/print_type_sizes/packed.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// padding and overall computed sizes can be quite different.
2121

2222
#![allow(dead_code)]
23+
#![feature(start)]
2324

2425
#[derive(Default)]
2526
#[repr(packed)]
@@ -42,7 +43,9 @@ struct Padded {
4243
d: u8,
4344
}
4445

45-
pub fn main() {
46+
#[start]
47+
fn start(_: isize, _: *const *const u8) -> isize {
4648
let _c: Packed = Default::default();
4749
let _d: Padded = Default::default();
50+
0
4851
}

src/test/ui/print_type_sizes/padding.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// aligned (while on most it is 8-byte aligned) and so the resulting
2020
// padding and overall computed sizes can be quite different.
2121

22+
#![feature(start)]
2223
#![allow(dead_code)]
2324

2425
struct S {
@@ -37,4 +38,7 @@ enum E2 {
3738
B(S),
3839
}
3940

40-
fn main() { }
41+
#[start]
42+
fn start(_: isize, _: *const *const u8) -> isize {
43+
0
44+
}

src/test/ui/print_type_sizes/repr-align.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// padding and overall computed sizes can be quite different.
2121
#![feature(attr_literals)]
2222
#![feature(repr_align)]
23+
#![feature(start)]
2324
#![allow(dead_code)]
2425

2526
#[repr(align(16))]
@@ -39,6 +40,8 @@ struct S {
3940
d: i8,
4041
}
4142

42-
fn main() {
43+
#[start]
44+
fn start(_: isize, _: *const *const u8) -> isize {
4345
let _s: S = Default::default();
46+
0
4447
}

src/test/ui/print_type_sizes/uninhabited.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
// must-compile-successfully
1313

1414
#![feature(never_type)]
15+
#![feature(start)]
1516

16-
pub fn main() {
17+
#[start]
18+
fn start(_: isize, _: *const *const u8) -> isize {
1719
let _x: Option<!> = None;
1820
let _y: Result<u32, !> = Ok(42);
21+
0
1922
}

src/test/ui/print_type_sizes/variants.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// 2. For an enum, the print-type-sizes output will also include the
2020
// size of each variant.
2121

22+
#![feature(start)]
23+
2224
pub struct SevenBytes([u8; 7]);
2325
pub struct FiftyBytes([u8; 50]);
2426

@@ -27,6 +29,8 @@ pub enum Enum {
2729
Large(FiftyBytes),
2830
}
2931

30-
pub fn main() {
32+
#[start]
33+
fn start(_: isize, _: *const *const u8) -> isize {
3134
let _e: Enum;
35+
0
3236
}

0 commit comments

Comments
 (0)