66// 10
77
88#![ allow( internal_features, unused_attributes) ]
9- #![ feature( auto_traits, lang_items, no_core, intrinsics, rustc_attrs, track_caller ) ]
9+ #![ feature( auto_traits, lang_items, no_core, intrinsics, rustc_attrs) ]
1010
1111#![ no_std]
1212#![ no_core]
1313#![ no_main]
1414
15- /*
16- * Core
17- */
15+ extern crate mini_core;
1816
19- // Because we don't have core yet.
20- #[ lang = "sized" ]
21- pub trait Sized { }
22-
23- #[ lang = "copy" ]
24- trait Copy {
25- }
26-
27- impl Copy for isize { }
28- impl Copy for * mut i32 { }
29- impl Copy for usize { }
30- impl Copy for u8 { }
31- impl Copy for i8 { }
32- impl Copy for i32 { }
33-
34- #[ lang = "receiver" ]
35- trait Receiver {
36- }
37-
38- #[ lang = "freeze" ]
39- pub ( crate ) unsafe auto trait Freeze { }
40-
41- #[ lang = "panic_location" ]
42- struct PanicLocation {
43- file : & ' static str ,
44- line : u32 ,
45- column : u32 ,
46- }
47-
48- mod libc {
49- #[ link( name = "c" ) ]
50- extern "C" {
51- pub fn puts ( s : * const u8 ) -> i32 ;
52- pub fn fflush ( stream : * mut i32 ) -> i32 ;
53- pub fn printf ( format : * const i8 , ...) -> i32 ;
54-
55- pub static stdout: * mut i32 ;
56- }
57- }
58-
59- mod intrinsics {
60- #[ rustc_nounwind]
61- #[ rustc_intrinsic]
62- #[ rustc_intrinsic_must_be_overridden]
63- pub fn abort ( ) -> ! {
64- loop { }
65- }
66- }
67-
68- #[ lang = "panic" ]
69- #[ track_caller]
70- #[ no_mangle]
71- pub fn panic ( _msg : & ' static str ) -> ! {
72- unsafe {
73- libc:: puts ( "Panicking\0 " as * const str as * const u8 ) ;
74- libc:: fflush ( libc:: stdout) ;
75- intrinsics:: abort ( ) ;
76- }
77- }
78-
79- #[ lang = "add" ]
80- trait Add < RHS = Self > {
81- type Output ;
82-
83- fn add ( self , rhs : RHS ) -> Self :: Output ;
84- }
85-
86- impl Add for u8 {
87- type Output = Self ;
88-
89- fn add ( self , rhs : Self ) -> Self {
90- self + rhs
91- }
92- }
93-
94- impl Add for i8 {
95- type Output = Self ;
96-
97- fn add ( self , rhs : Self ) -> Self {
98- self + rhs
99- }
100- }
101-
102- impl Add for i32 {
103- type Output = Self ;
104-
105- fn add ( self , rhs : Self ) -> Self {
106- self + rhs
107- }
108- }
109-
110- impl Add for usize {
111- type Output = Self ;
112-
113- fn add ( self , rhs : Self ) -> Self {
114- self + rhs
115- }
116- }
117-
118- impl Add for isize {
119- type Output = Self ;
120-
121- fn add ( self , rhs : Self ) -> Self {
122- self + rhs
123- }
124- }
125-
126- #[ track_caller]
127- #[ lang = "panic_const_add_overflow" ]
128- pub fn panic_const_add_overflow ( ) -> ! {
129- panic ( "attempt to add with overflow" ) ;
130- }
131-
132- /*
133- * Code
134- */
17+ use mini_core:: libc;
13518
13619fn inc_ref ( num : & mut isize ) -> isize {
13720 * num = * num + 5 ;
@@ -144,7 +27,7 @@ fn inc(num: isize) -> isize {
14427
14528
14629#[ no_mangle]
147- extern "C" fn main ( argc : i32 , _argv : * const * const u8 ) -> i32 {
30+ extern "C" fn main ( mut argc : isize , _argv : * const * const u8 ) -> i32 {
14831 argc = inc ( argc) ;
14932 unsafe {
15033 libc:: printf ( b"%ld\n \0 " as * const u8 as * const i8 , argc) ;
0 commit comments