]> git.lizzy.rs Git - rust.git/blob - src/libcore/lib.rs
RFC 2008: Stabilization
[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 #![allow(explicit_outlives_requirements)]
66 #![allow(incomplete_features)]
67
68 #![feature(allow_internal_unstable)]
69 #![feature(arbitrary_self_types)]
70 #![feature(asm)]
71 #![feature(bound_cloned)]
72 #![feature(cfg_target_has_atomic)]
73 #![feature(concat_idents)]
74 #![feature(const_fn)]
75 #![feature(const_fn_union)]
76 #![feature(const_generics)]
77 #![feature(custom_inner_attributes)]
78 #![feature(decl_macro)]
79 #![feature(doc_cfg)]
80 #![feature(doc_spotlight)]
81 #![feature(extern_types)]
82 #![feature(fundamental)]
83 #![feature(intrinsics)]
84 #![feature(is_sorted)]
85 #![feature(iter_once_with)]
86 #![feature(lang_items)]
87 #![feature(link_llvm_intrinsics)]
88 #![feature(never_type)]
89 #![feature(nll)]
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(transparent_unions)]
104 #![feature(unboxed_closures)]
105 #![feature(unsized_locals)]
106 #![feature(untagged_unions)]
107 #![feature(unwind_attributes)]
108 #![feature(doc_alias)]
109 #![feature(mmx_target_feature)]
110 #![feature(tbm_target_feature)]
111 #![feature(sse4a_target_feature)]
112 #![feature(arm_target_feature)]
113 #![feature(powerpc_target_feature)]
114 #![feature(mips_target_feature)]
115 #![feature(aarch64_target_feature)]
116 #![feature(wasm_target_feature)]
117 #![feature(avx512_target_feature)]
118 #![feature(cmpxchg16b_target_feature)]
119 #![feature(rtm_target_feature)]
120 #![feature(f16c_target_feature)]
121 #![feature(hexagon_target_feature)]
122 #![feature(const_int_conversion)]
123 #![feature(const_transmute)]
124 #![cfg_attr(bootstrap, feature(non_exhaustive))]
125 #![feature(structural_match)]
126 #![feature(abi_unadjusted)]
127 #![feature(adx_target_feature)]
128 #![feature(maybe_uninit_slice)]
129 #![feature(external_doc)]
130 #![feature(associated_type_bounds)]
131
132 #[prelude_import]
133 #[allow(unused)]
134 use prelude::v1::*;
135
136 #[macro_use]
137 mod macros;
138
139 #[macro_use]
140 mod internal_macros;
141
142 #[path = "num/int_macros.rs"]
143 #[macro_use]
144 mod int_macros;
145
146 #[path = "num/uint_macros.rs"]
147 #[macro_use]
148 mod uint_macros;
149
150 #[path = "num/isize.rs"] pub mod isize;
151 #[path = "num/i8.rs"]    pub mod i8;
152 #[path = "num/i16.rs"]   pub mod i16;
153 #[path = "num/i32.rs"]   pub mod i32;
154 #[path = "num/i64.rs"]   pub mod i64;
155 #[path = "num/i128.rs"]  pub mod i128;
156
157 #[path = "num/usize.rs"] pub mod usize;
158 #[path = "num/u8.rs"]    pub mod u8;
159 #[path = "num/u16.rs"]   pub mod u16;
160 #[path = "num/u32.rs"]   pub mod u32;
161 #[path = "num/u64.rs"]   pub mod u64;
162 #[path = "num/u128.rs"]  pub mod u128;
163
164 #[path = "num/f32.rs"]   pub mod f32;
165 #[path = "num/f64.rs"]   pub mod f64;
166
167 #[macro_use]
168 pub mod num;
169
170 /* The libcore prelude, not as all-encompassing as the libstd prelude */
171
172 pub mod prelude;
173
174 /* Core modules for ownership management */
175
176 pub mod intrinsics;
177 pub mod mem;
178 pub mod ptr;
179 pub mod hint;
180
181 /* Core language traits */
182
183 pub mod marker;
184 pub mod ops;
185 pub mod cmp;
186 pub mod clone;
187 pub mod default;
188 pub mod convert;
189 pub mod borrow;
190
191 /* Core types and methods on primitives */
192
193 pub mod any;
194 pub mod array;
195 pub mod ascii;
196 pub mod sync;
197 pub mod cell;
198 pub mod char;
199 pub mod panic;
200 pub mod panicking;
201 pub mod pin;
202 pub mod iter;
203 pub mod option;
204 pub mod raw;
205 pub mod result;
206 pub mod ffi;
207
208 pub mod slice;
209 pub mod str;
210 pub mod hash;
211 pub mod fmt;
212 pub mod time;
213
214 pub mod unicode;
215
216 /* Async */
217 pub mod future;
218 pub mod task;
219
220 /* Heap memory allocator trait */
221 #[allow(missing_docs)]
222 pub mod alloc;
223
224 // note: does not need to be public
225 mod bool;
226 mod tuple;
227 mod unit;
228
229 // Pull in the `core_arch` crate directly into libcore. The contents of
230 // `core_arch` are in a different repository: rust-lang/stdarch.
231 //
232 // `core_arch` depends on libcore, but the contents of this module are
233 // set up in such a way that directly pulling it here works such that the
234 // crate uses the this crate as its libcore.
235 #[path = "../stdarch/crates/core_arch/src/mod.rs"]
236 #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
237 #[unstable(feature = "stdsimd", issue = "48556")]
238 mod core_arch;
239
240 #[stable(feature = "simd_arch", since = "1.27.0")]
241 pub use core_arch::arch;