]> git.lizzy.rs Git - rust.git/blob - src/libcore/lib.rs
Auto merge of #50409 - KiChjang:issue-50343, r=nikomatsakis
[rust.git] / src / libcore / lib.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! # The Rust Core Library
12 //!
13 //! The Rust Core Library is the dependency-free[^free] foundation of [The
14 //! Rust Standard Library](../std/index.html). It is the portable glue
15 //! between the language and its libraries, defining the intrinsic and
16 //! primitive building blocks of all Rust code. It links to no
17 //! upstream libraries, no system libraries, and no libc.
18 //!
19 //! [^free]: Strictly speaking, there are some symbols which are needed but
20 //!          they aren't always necessary.
21 //!
22 //! The core library is *minimal*: it isn't even aware of heap allocation,
23 //! nor does it provide concurrency or I/O. These things require
24 //! platform integration, and this library is platform-agnostic.
25 //!
26 //! # How to use the core library
27 //!
28 //! Please note that all of these details are currently not considered stable.
29 //!
30 // FIXME: Fill me in with more detail when the interface settles
31 //! This library is built on the assumption of a few existing symbols:
32 //!
33 //! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
34 //!   often generated by LLVM. Additionally, this library can make explicit
35 //!   calls to these functions. Their signatures are the same as found in C.
36 //!   These functions are often provided by the system libc, but can also be
37 //!   provided by the [rlibc crate](https://crates.io/crates/rlibc).
38 //!
39 //! * `rust_begin_panic` - This function takes four arguments, a
40 //!   `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments
41 //!   dictate the panic message, the file at which panic was invoked, and the
42 //!   line and column inside the file. It is up to consumers of this core
43 //!   library to define this panic function; it is only required to never
44 //!   return. This requires a `lang` attribute named `panic_fmt`.
45 //!
46 //! * `rust_eh_personality` - is used by the failure mechanisms of the
47 //!    compiler. This is often mapped to GCC's personality function, but crates
48 //!    which do not trigger a panic can be assured that this function is never
49 //!    called. The `lang` attribute is called `eh_personality`.
50
51 // Since libcore defines many fundamental lang items, all tests live in a
52 // separate crate, libcoretest, to avoid bizarre issues.
53
54 #![stable(feature = "core", since = "1.6.0")]
55 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
56        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
57        html_root_url = "https://doc.rust-lang.org/nightly/",
58        html_playground_url = "https://play.rust-lang.org/",
59        issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
60        test(no_crate_inject, attr(deny(warnings))),
61        test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
62
63 #![no_core]
64 #![deny(missing_docs)]
65 #![deny(missing_debug_implementations)]
66
67 #![feature(allow_internal_unstable)]
68 #![feature(asm)]
69 #![feature(associated_type_defaults)]
70 #![feature(attr_literals)]
71 #![feature(cfg_target_has_atomic)]
72 #![feature(concat_idents)]
73 #![feature(const_fn)]
74 #![feature(core_float)]
75 #![feature(custom_attribute)]
76 #![feature(doc_cfg)]
77 #![feature(doc_spotlight)]
78 #![feature(extern_types)]
79 #![feature(fundamental)]
80 #![feature(intrinsics)]
81 #![feature(iterator_flatten)]
82 #![feature(iterator_repeat_with)]
83 #![feature(lang_items)]
84 #![feature(link_llvm_intrinsics)]
85 #![feature(never_type)]
86 #![feature(exhaustive_patterns)]
87 #![feature(macro_at_most_once_rep)]
88 #![feature(no_core)]
89 #![feature(on_unimplemented)]
90 #![feature(optin_builtin_traits)]
91 #![feature(prelude_import)]
92 #![feature(repr_simd, platform_intrinsics)]
93 #![feature(rustc_attrs)]
94 #![feature(rustc_const_unstable)]
95 #![feature(simd_ffi)]
96 #![feature(core_slice_ext)]
97 #![feature(core_str_ext)]
98 #![feature(specialization)]
99 #![feature(staged_api)]
100 #![feature(stmt_expr_attributes)]
101 #![feature(unboxed_closures)]
102 #![feature(untagged_unions)]
103 #![feature(unwind_attributes)]
104 #![feature(doc_alias)]
105 #![feature(inclusive_range_methods)]
106
107 #![cfg_attr(not(stage0), feature(mmx_target_feature))]
108 #![cfg_attr(not(stage0), feature(tbm_target_feature))]
109 #![cfg_attr(not(stage0), feature(sse4a_target_feature))]
110 #![cfg_attr(not(stage0), feature(arm_target_feature))]
111 #![cfg_attr(not(stage0), feature(powerpc_target_feature))]
112 #![cfg_attr(not(stage0), feature(mips_target_feature))]
113 #![cfg_attr(not(stage0), feature(aarch64_target_feature))]
114
115 #![cfg_attr(stage0, feature(target_feature))]
116 #![cfg_attr(stage0, feature(cfg_target_feature))]
117 #![cfg_attr(stage0, feature(fn_must_use))]
118
119 #[prelude_import]
120 #[allow(unused)]
121 use prelude::v1::*;
122
123 #[macro_use]
124 mod macros;
125
126 #[macro_use]
127 mod internal_macros;
128
129 #[path = "num/int_macros.rs"]
130 #[macro_use]
131 mod int_macros;
132
133 #[path = "num/uint_macros.rs"]
134 #[macro_use]
135 mod uint_macros;
136
137 #[path = "num/isize.rs"] pub mod isize;
138 #[path = "num/i8.rs"]    pub mod i8;
139 #[path = "num/i16.rs"]   pub mod i16;
140 #[path = "num/i32.rs"]   pub mod i32;
141 #[path = "num/i64.rs"]   pub mod i64;
142 #[path = "num/i128.rs"]   pub mod i128;
143
144 #[path = "num/usize.rs"] pub mod usize;
145 #[path = "num/u8.rs"]    pub mod u8;
146 #[path = "num/u16.rs"]   pub mod u16;
147 #[path = "num/u32.rs"]   pub mod u32;
148 #[path = "num/u64.rs"]   pub mod u64;
149 #[path = "num/u128.rs"]   pub mod u128;
150
151 #[path = "num/f32.rs"]   pub mod f32;
152 #[path = "num/f64.rs"]   pub mod f64;
153
154 #[macro_use]
155 pub mod num;
156
157 /* The libcore prelude, not as all-encompassing as the libstd prelude */
158
159 pub mod prelude;
160
161 /* Core modules for ownership management */
162
163 pub mod intrinsics;
164 pub mod mem;
165 pub mod nonzero;
166 pub mod ptr;
167 pub mod hint;
168
169 /* Core language traits */
170
171 pub mod marker;
172 pub mod ops;
173 pub mod cmp;
174 pub mod clone;
175 pub mod default;
176 pub mod convert;
177 pub mod borrow;
178
179 /* Core types and methods on primitives */
180
181 pub mod any;
182 pub mod array;
183 pub mod ascii;
184 pub mod sync;
185 pub mod cell;
186 pub mod char;
187 pub mod panic;
188 pub mod panicking;
189 pub mod iter;
190 pub mod option;
191 pub mod raw;
192 pub mod result;
193
194 pub mod slice;
195 pub mod str;
196 pub mod hash;
197 pub mod fmt;
198 pub mod time;
199
200 pub mod unicode;
201
202 /* Heap memory allocator trait */
203 #[allow(missing_docs)]
204 pub mod alloc;
205
206 #[unstable(feature = "allocator_api", issue = "32838")]
207 #[rustc_deprecated(since = "1.27.0", reason = "module renamed to `alloc`")]
208 /// Use the `alloc` module instead.
209 pub mod heap {
210     pub use alloc::*;
211 }
212
213 // note: does not need to be public
214 mod iter_private;
215 mod tuple;
216 mod unit;
217
218 // Pull in the the `coresimd` crate directly into libcore. This is where all the
219 // architecture-specific (and vendor-specific) intrinsics are defined. AKA
220 // things like SIMD and such. Note that the actual source for all this lies in a
221 // different repository, rust-lang-nursery/stdsimd. That's why the setup here is
222 // a bit wonky.
223 #[allow(unused_macros)]
224 macro_rules! test_v16 { ($item:item) => {}; }
225 #[allow(unused_macros)]
226 macro_rules! test_v32 { ($item:item) => {}; }
227 #[allow(unused_macros)]
228 macro_rules! test_v64 { ($item:item) => {}; }
229 #[allow(unused_macros)]
230 macro_rules! test_v128 { ($item:item) => {}; }
231 #[allow(unused_macros)]
232 macro_rules! test_v256 { ($item:item) => {}; }
233 #[allow(unused_macros)]
234 macro_rules! test_v512 { ($item:item) => {}; }
235 #[allow(unused_macros)]
236 macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } }
237 #[path = "../stdsimd/coresimd/mod.rs"]
238 #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
239 #[unstable(feature = "stdsimd", issue = "48556")]
240 #[cfg(not(stage0))] // allow changes to how stdsimd works in stage0
241 mod coresimd;
242
243 #[unstable(feature = "stdsimd", issue = "48556")]
244 #[cfg(not(stage0))]
245 pub use coresimd::simd;
246 #[stable(feature = "simd_arch", since = "1.27.0")]
247 #[cfg(not(stage0))]
248 pub use coresimd::arch;