]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_gcc/tests/run/structs.rs
Auto merge of #92419 - erikdesjardins:coldland, r=nagisa
[rust.git] / compiler / rustc_codegen_gcc / tests / run / structs.rs
1 // Compiler:
2 //
3 // Run-time:
4 //   status: 0
5 //   stdout: 1
6 //     2
7
8 #![feature(auto_traits, lang_items, no_core, start, intrinsics)]
9
10 #![no_std]
11 #![no_core]
12
13 /*
14  * Core
15  */
16
17 // Because we don't have core yet.
18 #[lang = "sized"]
19 pub trait Sized {}
20
21 #[lang = "copy"]
22 trait Copy {
23 }
24
25 impl Copy for isize {}
26
27 #[lang = "receiver"]
28 trait Receiver {
29 }
30
31 #[lang = "freeze"]
32 pub(crate) unsafe auto trait Freeze {}
33
34 mod libc {
35     #[link(name = "c")]
36     extern "C" {
37         pub fn printf(format: *const i8, ...) -> i32;
38     }
39 }
40
41 /*
42  * Code
43  */
44
45 struct Test {
46     field: isize,
47 }
48
49 struct Two {
50     two: isize,
51 }
52
53 fn one() -> isize {
54     1
55 }
56
57 #[start]
58 fn main(mut argc: isize, _argv: *const *const u8) -> isize {
59     let test = Test {
60         field: one(),
61     };
62     let two = Two {
63         two: 2,
64     };
65     unsafe {
66         libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field);
67         libc::printf(b"%ld\n\0" as *const u8 as *const i8, two.two);
68     }
69     0
70 }