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