]> git.lizzy.rs Git - rust.git/blob - src/libcore/lib.rs
Rollup merge of #63055 - Mark-Simulacrum:save-analysis-clean-2, r=Xanewok
[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
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(custom_inner_attributes)]
77 #![feature(decl_macro)]
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(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_slice_len)]
123 #![feature(const_str_as_bytes)]
124 #![feature(const_str_len)]
125 #![feature(const_int_conversion)]
126 #![feature(const_transmute)]
127 #![feature(non_exhaustive)]
128 #![feature(structural_match)]
129 #![feature(abi_unadjusted)]
130 #![feature(adx_target_feature)]
131 #![feature(maybe_uninit_slice, maybe_uninit_array)]
132 #![feature(external_doc)]
133 #![feature(mem_take)]
134
135 #[prelude_import]
136 #[allow(unused)]
137 use prelude::v1::*;
138
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/isize.rs"] pub mod isize;
154 #[path = "num/i8.rs"]    pub mod i8;
155 #[path = "num/i16.rs"]   pub mod i16;
156 #[path = "num/i32.rs"]   pub mod i32;
157 #[path = "num/i64.rs"]   pub mod i64;
158 #[path = "num/i128.rs"]  pub mod i128;
159
160 #[path = "num/usize.rs"] pub mod usize;
161 #[path = "num/u8.rs"]    pub mod u8;
162 #[path = "num/u16.rs"]   pub mod u16;
163 #[path = "num/u32.rs"]   pub mod u32;
164 #[path = "num/u64.rs"]   pub mod u64;
165 #[path = "num/u128.rs"]  pub mod u128;
166
167 #[path = "num/f32.rs"]   pub mod f32;
168 #[path = "num/f64.rs"]   pub mod f64;
169
170 #[macro_use]
171 pub mod num;
172
173 /* The libcore prelude, not as all-encompassing as the libstd prelude */
174
175 pub mod prelude;
176
177 /* Core modules for ownership management */
178
179 pub mod intrinsics;
180 pub mod mem;
181 pub mod ptr;
182 pub mod hint;
183
184 /* Core language traits */
185
186 pub mod marker;
187 pub mod ops;
188 pub mod cmp;
189 pub mod clone;
190 pub mod default;
191 pub mod convert;
192 pub mod borrow;
193
194 /* Core types and methods on primitives */
195
196 pub mod any;
197 pub mod array;
198 pub mod ascii;
199 pub mod sync;
200 pub mod cell;
201 pub mod char;
202 pub mod panic;
203 pub mod panicking;
204 pub mod pin;
205 pub mod iter;
206 pub mod option;
207 pub mod raw;
208 pub mod result;
209 pub mod ffi;
210
211 pub mod slice;
212 pub mod str;
213 pub mod hash;
214 pub mod fmt;
215 pub mod time;
216
217 pub mod unicode;
218
219 /* Async */
220 pub mod future;
221 pub mod task;
222
223 /* Heap memory allocator trait */
224 #[allow(missing_docs)]
225 pub mod alloc;
226
227 // note: does not need to be public
228 mod tuple;
229 mod unit;
230
231 // Pull in the `core_arch` crate directly into libcore. The contents of
232 // `core_arch` are in a different repository: rust-lang/stdarch.
233 //
234 // `core_arch` depends on libcore, but the contents of this module are
235 // set up in such a way that directly pulling it here works such that the
236 // crate uses the this crate as its libcore.
237 #[path = "../stdarch/crates/core_arch/src/mod.rs"]
238 #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
239 #[unstable(feature = "stdsimd", issue = "48556")]
240 mod core_arch;
241
242 #[stable(feature = "simd_arch", since = "1.27.0")]
243 pub use core_arch::arch;