7
7
// 5
8
8
// 10
9
9
10
- #![ feature( arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs) ]
11
- #![ allow( internal_features) ]
10
+ #![ feature( no_core, start) ]
12
11
13
12
#![ no_std]
14
13
#![ no_core]
15
14
16
- /*
17
- * Core
18
- */
19
-
20
- // Because we don't have core yet.
21
- #[ lang = "sized" ]
22
- pub trait Sized { }
23
-
24
- #[ lang = "copy" ]
25
- trait Copy {
26
- }
27
-
28
- impl Copy for isize { }
29
- impl Copy for usize { }
30
- impl Copy for i32 { }
31
- impl Copy for u8 { }
32
- impl Copy for i8 { }
33
- impl Copy for i16 { }
34
- impl < T : ?Sized > Copy for * mut T { }
35
-
36
- #[ lang = "legacy_receiver" ]
37
- trait LegacyReceiver {
38
- }
39
-
40
- #[ lang = "freeze" ]
41
- pub ( crate ) unsafe auto trait Freeze { }
15
+ extern crate mini_core;
42
16
43
17
mod libc {
44
18
#[ link( name = "c" ) ]
@@ -48,182 +22,6 @@ mod libc {
48
22
}
49
23
}
50
24
51
- #[ lang = "index" ]
52
- pub trait Index < Idx : ?Sized > {
53
- type Output : ?Sized ;
54
- fn index ( & self , index : Idx ) -> & Self :: Output ;
55
- }
56
-
57
- impl < T > Index < usize > for [ T ; 3 ] {
58
- type Output = T ;
59
-
60
- fn index ( & self , index : usize ) -> & Self :: Output {
61
- & self [ index]
62
- }
63
- }
64
-
65
- impl < T > Index < usize > for [ T ] {
66
- type Output = T ;
67
-
68
- fn index ( & self , index : usize ) -> & Self :: Output {
69
- & self [ index]
70
- }
71
- }
72
-
73
- #[ lang = "drop_in_place" ]
74
- #[ allow( unconditional_recursion) ]
75
- pub unsafe fn drop_in_place < T : ?Sized > ( to_drop : * mut T ) {
76
- // Code here does not matter - this is replaced by the
77
- // real drop glue by the compiler.
78
- drop_in_place ( to_drop) ;
79
- }
80
-
81
- #[ lang = "panic" ]
82
- #[ track_caller]
83
- #[ no_mangle]
84
- pub fn panic ( _msg : & ' static str ) -> ! {
85
- unsafe {
86
- libc:: puts ( "Panicking\0 " as * const str as * const u8 ) ;
87
- intrinsics:: abort ( ) ;
88
- }
89
- }
90
-
91
- #[ lang = "panic_location" ]
92
- struct PanicLocation {
93
- file : & ' static str ,
94
- line : u32 ,
95
- column : u32 ,
96
- }
97
-
98
- #[ lang = "panic_bounds_check" ]
99
- #[ track_caller]
100
- #[ no_mangle]
101
- fn panic_bounds_check ( index : usize , len : usize ) -> ! {
102
- unsafe {
103
- libc:: printf ( "index out of bounds: the len is %d but the index is %d\n \0 " as * const str as * const i8 , len, index) ;
104
- intrinsics:: abort ( ) ;
105
- }
106
- }
107
-
108
- mod intrinsics {
109
- #[ rustc_nounwind]
110
- #[ rustc_intrinsic]
111
- #[ rustc_intrinsic_must_be_overridden]
112
- pub fn abort ( ) -> ! {
113
- loop { }
114
- }
115
- }
116
-
117
- #[ lang = "add" ]
118
- trait Add < RHS = Self > {
119
- type Output ;
120
-
121
- fn add ( self , rhs : RHS ) -> Self :: Output ;
122
- }
123
-
124
- impl Add for u8 {
125
- type Output = Self ;
126
-
127
- fn add ( self , rhs : Self ) -> Self {
128
- self + rhs
129
- }
130
- }
131
-
132
- impl Add for i8 {
133
- type Output = Self ;
134
-
135
- fn add ( self , rhs : Self ) -> Self {
136
- self + rhs
137
- }
138
- }
139
-
140
- impl Add for i32 {
141
- type Output = Self ;
142
-
143
- fn add ( self , rhs : Self ) -> Self {
144
- self + rhs
145
- }
146
- }
147
-
148
- impl Add for usize {
149
- type Output = Self ;
150
-
151
- fn add ( self , rhs : Self ) -> Self {
152
- self + rhs
153
- }
154
- }
155
-
156
- impl Add for isize {
157
- type Output = Self ;
158
-
159
- fn add ( self , rhs : Self ) -> Self {
160
- self + rhs
161
- }
162
- }
163
-
164
- #[ lang = "sub" ]
165
- pub trait Sub < RHS = Self > {
166
- type Output ;
167
-
168
- fn sub ( self , rhs : RHS ) -> Self :: Output ;
169
- }
170
-
171
- impl Sub for usize {
172
- type Output = Self ;
173
-
174
- fn sub ( self , rhs : Self ) -> Self {
175
- self - rhs
176
- }
177
- }
178
-
179
- impl Sub for isize {
180
- type Output = Self ;
181
-
182
- fn sub ( self , rhs : Self ) -> Self {
183
- self - rhs
184
- }
185
- }
186
-
187
- impl Sub for u8 {
188
- type Output = Self ;
189
-
190
- fn sub ( self , rhs : Self ) -> Self {
191
- self - rhs
192
- }
193
- }
194
-
195
- impl Sub for i8 {
196
- type Output = Self ;
197
-
198
- fn sub ( self , rhs : Self ) -> Self {
199
- self - rhs
200
- }
201
- }
202
-
203
- impl Sub for i16 {
204
- type Output = Self ;
205
-
206
- fn sub ( self , rhs : Self ) -> Self {
207
- self - rhs
208
- }
209
- }
210
-
211
- #[ track_caller]
212
- #[ lang = "panic_const_add_overflow" ]
213
- pub fn panic_const_add_overflow ( ) -> ! {
214
- panic ( "attempt to add with overflow" ) ;
215
- }
216
-
217
- #[ track_caller]
218
- #[ lang = "panic_const_sub_overflow" ]
219
- pub fn panic_const_sub_overflow ( ) -> ! {
220
- panic ( "attempt to subtract with overflow" ) ;
221
- }
222
-
223
- /*
224
- * Code
225
- */
226
-
227
25
static mut ONE : usize = 1 ;
228
26
229
27
fn make_array ( ) -> [ u8 ; 3 ] {
0 commit comments