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