]> git.lizzy.rs Git - rust.git/blob - tests/run/return-tuple.rs
Initial commit
[rust.git] / tests / run / return-tuple.rs
1 // Compiler:
2 //
3 // Run-time:
4 //   status: 0
5 //   stdout: 10
6 //     10
7 //     42
8
9 #![feature(auto_traits, lang_items, no_core, start, intrinsics)]
10
11 #![no_std]
12 #![no_core]
13
14 #[lang = "copy"]
15 pub unsafe trait Copy {}
16
17 unsafe impl Copy for bool {}
18 unsafe impl Copy for u8 {}
19 unsafe impl Copy for u16 {}
20 unsafe impl Copy for u32 {}
21 unsafe impl Copy for u64 {}
22 unsafe impl Copy for usize {}
23 unsafe impl Copy for i8 {}
24 unsafe impl Copy for i16 {}
25 unsafe impl Copy for i32 {}
26 unsafe impl Copy for isize {}
27 unsafe impl Copy for f32 {}
28 unsafe impl Copy for char {}
29
30 mod libc {
31     #[link(name = "c")]
32     extern "C" {
33         pub fn printf(format: *const i8, ...) -> i32;
34     }
35 }
36
37 /*
38  * Core
39  */
40
41 // Because we don't have core yet.
42 #[lang = "sized"]
43 pub trait Sized {}
44
45 #[lang = "receiver"]
46 trait Receiver {
47 }
48
49 #[lang = "freeze"]
50 pub(crate) unsafe auto trait Freeze {}
51
52 /*
53  * Code
54  */
55
56 fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) {
57     (
58         a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8,
59         b as u32,
60     )
61 }
62
63 #[start]
64 fn main(argc: isize, _argv: *const *const u8) -> isize {
65     let (a, b, c, d, e, f, g, h, i, j) = int_cast(10, 42);
66     unsafe {
67         libc::printf(b"%d\n\0" as *const u8 as *const i8, c);
68         libc::printf(b"%ld\n\0" as *const u8 as *const i8, d);
69         libc::printf(b"%ld\n\0" as *const u8 as *const i8, j);
70     }
71     0
72 }