]> git.lizzy.rs Git - rust.git/blob - src/libcore/lib.rs
4a70329b64bc983a7d43b0b4214be77d892c8447
[rust.git] / src / libcore / lib.rs
1 //! # The Rust Core Library
2 //!
3 //! The Rust Core Library is the dependency-free[^free] foundation of [The
4 //! Rust Standard Library](../std/index.html). It is the portable glue
5 //! between the language and its libraries, defining the intrinsic and
6 //! primitive building blocks of all Rust code. It links to no
7 //! upstream libraries, no system libraries, and no libc.
8 //!
9 //! [^free]: Strictly speaking, there are some symbols which are needed but
10 //!          they aren't always necessary.
11 //!
12 //! The core library is *minimal*: it isn't even aware of heap allocation,
13 //! nor does it provide concurrency or I/O. These things require
14 //! platform integration, and this library is platform-agnostic.
15 //!
16 //! # How to use the core library
17 //!
18 //! Please note that all of these details are currently not considered stable.
19 //!
20 // FIXME: Fill me in with more detail when the interface settles
21 //! This library is built on the assumption of a few existing symbols:
22 //!
23 //! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
24 //!   often generated by LLVM. Additionally, this library can make explicit
25 //!   calls to these functions. Their signatures are the same as found in C.
26 //!   These functions are often provided by the system libc, but can also be
27 //!   provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins).
28 //!
29 //! * `rust_begin_panic` - This function takes four arguments, a
30 //!   `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments
31 //!   dictate the panic message, the file at which panic was invoked, and the
32 //!   line and column inside the file. It is up to consumers of this core
33 //!   library to define this panic function; it is only required to never
34 //!   return. This requires a `lang` attribute named `panic_impl`.
35 //!
36 //! * `rust_eh_personality` - is used by the failure mechanisms of the
37 //!    compiler. This is often mapped to GCC's personality function, but crates
38 //!    which do not trigger a panic can be assured that this function is never
39 //!    called. The `lang` attribute is called `eh_personality`.
40
41 // Since libcore defines many fundamental lang items, all tests live in a
42 // separate crate, libcoretest, to avoid bizarre issues.
43 //
44 // Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
45 // this, both the generated test artifact and the linked libtest (which
46 // transitively includes libcore) will both define the same set of lang items,
47 // and this will cause the E0152 "duplicate lang item found" error. See
48 // discussion in #50466 for details.
49 //
50 // This cfg won't affect doc tests.
51 #![cfg(not(test))]
52
53 #![stable(feature = "core", since = "1.6.0")]
54 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
55        html_playground_url = "https://play.rust-lang.org/",
56        issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
57        test(no_crate_inject, attr(deny(warnings))),
58        test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
59 #![no_core]
60
61 #![warn(deprecated_in_future)]
62 #![warn(missing_docs)]
63 #![warn(missing_debug_implementations)]
64 #![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
65
66 #![deny(rust_2018_idioms)]
67 #![allow(explicit_outlives_requirements)]
68
69 #![feature(allow_internal_unstable)]
70 #![feature(arbitrary_self_types)]
71 #![feature(asm)]
72 #![feature(associated_type_defaults)]
73 #![feature(cfg_target_has_atomic)]
74 #![feature(concat_idents)]
75 #![feature(const_fn)]
76 #![feature(const_fn_union)]
77 #![feature(custom_attribute)]
78 #![feature(doc_cfg)]
79 #![feature(doc_spotlight)]
80 #![feature(extern_types)]
81 #![feature(fundamental)]
82 #![feature(intrinsics)]
83 #![feature(is_sorted)]
84 #![feature(iter_once_with)]
85 #![feature(lang_items)]
86 #![feature(link_llvm_intrinsics)]
87 #![feature(never_type)]
88 #![feature(nll)]
89 #![feature(bind_by_move_pattern_guards)]
90 #![feature(exhaustive_patterns)]
91 #![feature(no_core)]
92 #![feature(on_unimplemented)]
93 #![feature(optin_builtin_traits)]
94 #![feature(prelude_import)]
95 #![feature(repr_simd, platform_intrinsics)]
96 #![feature(rustc_attrs)]
97 #![feature(rustc_const_unstable)]
98 #![feature(simd_ffi)]
99 #![feature(specialization)]
100 #![feature(staged_api)]
101 #![feature(std_internals)]
102 #![feature(stmt_expr_attributes)]
103 #![feature(unboxed_closures)]
104 #![feature(unsized_locals)]
105 #![feature(untagged_unions)]
106 #![feature(unwind_attributes)]
107 #![feature(doc_alias)]
108 #![feature(mmx_target_feature)]
109 #![feature(tbm_target_feature)]
110 #![feature(sse4a_target_feature)]
111 #![feature(arm_target_feature)]
112 #![feature(powerpc_target_feature)]
113 #![feature(mips_target_feature)]
114 #![feature(aarch64_target_feature)]
115 #![feature(wasm_target_feature)]
116 #![feature(avx512_target_feature)]
117 #![feature(cmpxchg16b_target_feature)]
118 #![feature(const_slice_len)]
119 #![feature(const_str_as_bytes)]
120 #![feature(const_str_len)]
121 #![feature(const_int_conversion)]
122 #![feature(const_transmute)]
123 #![feature(reverse_bits)]
124 #![feature(non_exhaustive)]
125 #![feature(structural_match)]
126 #![feature(abi_unadjusted)]
127 #![feature(adx_target_feature)]
128 #![feature(maybe_uninit_slice, maybe_uninit_array)]
129 #![feature(external_doc)]
130
131 #[prelude_import]
132 #[allow(unused)]
133 use prelude::v1::*;
134
135 #[macro_use]
136 mod macros;
137
138 #[macro_use]
139 mod internal_macros;
140
141 #[path = "num/int_macros.rs"]
142 #[macro_use]
143 mod int_macros;
144
145 #[path = "num/uint_macros.rs"]
146 #[macro_use]
147 mod uint_macros;
148
149 #[path = "num/isize.rs"] pub mod isize;
150 #[path = "num/i8.rs"]    pub mod i8;
151 #[path = "num/i16.rs"]   pub mod i16;
152 #[path = "num/i32.rs"]   pub mod i32;
153 #[path = "num/i64.rs"]   pub mod i64;
154 #[path = "num/i128.rs"]  pub mod i128;
155
156 #[path = "num/usize.rs"] pub mod usize;
157 #[path = "num/u8.rs"]    pub mod u8;
158 #[path = "num/u16.rs"]   pub mod u16;
159 #[path = "num/u32.rs"]   pub mod u32;
160 #[path = "num/u64.rs"]   pub mod u64;
161 #[path = "num/u128.rs"]  pub mod u128;
162
163 #[path = "num/f32.rs"]   pub mod f32;
164 #[path = "num/f64.rs"]   pub mod f64;
165
166 #[macro_use]
167 pub mod num;
168
169 /* The libcore prelude, not as all-encompassing as the libstd prelude */
170
171 pub mod prelude;
172
173 /* Core modules for ownership management */
174
175 pub mod intrinsics;
176 pub mod mem;
177 pub mod ptr;
178 pub mod hint;
179
180 /* Core language traits */
181
182 pub mod marker;
183 pub mod ops;
184 pub mod cmp;
185 pub mod clone;
186 pub mod default;
187 pub mod convert;
188 pub mod borrow;
189
190 /* Core types and methods on primitives */
191
192 pub mod any;
193 pub mod array;
194 pub mod ascii;
195 pub mod sync;
196 pub mod cell;
197 pub mod char;
198 pub mod panic;
199 pub mod panicking;
200 pub mod pin;
201 pub mod iter;
202 pub mod option;
203 pub mod raw;
204 pub mod result;
205 pub mod ffi;
206
207 pub mod slice;
208 pub mod str;
209 pub mod hash;
210 pub mod fmt;
211 pub mod time;
212
213 pub mod unicode;
214
215 /* Async */
216 pub mod future;
217 pub mod task;
218
219 /* Heap memory allocator trait */
220 #[allow(missing_docs)]
221 pub mod alloc;
222
223 // note: does not need to be public
224 mod tuple;
225 mod unit;
226
227 // Pull in the `core_arch` crate directly into libcore. The contents of
228 // `core_arch` are in a different repository: rust-lang-nursery/stdsimd.
229 //
230 // `core_arch` depends on libcore, but the contents of this module are
231 // set up in such a way that directly pulling it here works such that the
232 // crate uses the this crate as its libcore.
233 #[path = "../stdsimd/crates/core_arch/src/mod.rs"]
234 #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
235 #[unstable(feature = "stdsimd", issue = "48556")]
236 mod core_arch;
237
238 #[stable(feature = "simd_arch", since = "1.27.0")]
239 pub use core_arch::arch;