1 //! # The Rust Core Library
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.
9 //! [^free]: Strictly speaking, there are some symbols which are needed but
10 //! they aren't always necessary.
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.
16 //! # How to use the core library
18 //! Please note that all of these details are currently not considered stable.
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:
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).
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`.
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`.
41 // Since libcore defines many fundamental lang items, all tests live in a
42 // separate crate, libcoretest, to avoid bizarre issues.
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 "found duplicate lang item" error. See
48 // discussion in #50466 for details.
50 // This cfg won't affect doc tests.
52 #![stable(feature = "core", since = "1.6.0")]
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)))
61 #![warn(deprecated_in_future)]
62 #![warn(missing_docs)]
63 #![warn(missing_debug_implementations)]
64 #![allow(explicit_outlives_requirements)]
65 #![allow(incomplete_features)]
66 #![feature(allow_internal_unstable)]
67 #![feature(arbitrary_self_types)]
69 #![feature(bound_cloned)]
70 #![feature(cfg_target_has_atomic)]
71 #![feature(concat_idents)]
72 #![feature(const_alloc_layout)]
73 #![feature(const_discriminant)]
74 #![feature(const_checked_int_methods)]
75 #![feature(const_euclidean_int_methods)]
76 #![feature(const_overflowing_int_methods)]
77 #![feature(const_int_unchecked_arith)]
78 #![feature(const_int_pow)]
79 #![feature(constctlz)]
80 #![feature(const_panic)]
81 #![feature(const_fn_union)]
82 #![feature(const_generics)]
83 #![feature(const_option)]
84 #![feature(const_ptr_offset)]
85 #![feature(const_ptr_offset_from)]
86 #![feature(const_raw_ptr_comparison)]
87 #![feature(const_result)]
88 #![feature(const_slice_from_raw_parts)]
89 #![feature(const_slice_ptr_len)]
90 #![feature(const_size_of_val)]
91 #![feature(const_align_of_val)]
92 #![feature(const_type_name)]
93 #![feature(const_likely)]
94 #![feature(const_unreachable_unchecked)]
95 #![feature(custom_inner_attributes)]
96 #![feature(decl_macro)]
98 #![cfg_attr(not(bootstrap), feature(doc_spotlight))]
99 #![feature(duration_consts_2)]
100 #![feature(extern_types)]
101 #![feature(fundamental)]
102 #![feature(intrinsics)]
103 #![feature(try_find)]
104 #![feature(is_sorted)]
105 #![feature(lang_items)]
106 #![feature(link_llvm_intrinsics)]
107 #![feature(llvm_asm)]
108 #![feature(negative_impls)]
109 #![feature(never_type)]
111 #![feature(exhaustive_patterns)]
113 #![feature(optin_builtin_traits)]
114 #![feature(or_patterns)]
115 #![feature(prelude_import)]
116 #![feature(repr_simd, platform_intrinsics)]
117 #![feature(rustc_attrs)]
118 #![feature(simd_ffi)]
119 #![feature(specialization)]
120 #![feature(staged_api)]
121 #![feature(std_internals)]
122 #![feature(stmt_expr_attributes)]
123 #![feature(transparent_unions)]
124 #![feature(unboxed_closures)]
125 #![feature(unsized_locals)]
126 #![feature(untagged_unions)]
127 #![feature(unwind_attributes)]
128 #![feature(variant_count)]
129 #![feature(doc_alias)]
130 #![feature(mmx_target_feature)]
131 #![feature(tbm_target_feature)]
132 #![feature(sse4a_target_feature)]
133 #![feature(arm_target_feature)]
134 #![feature(powerpc_target_feature)]
135 #![feature(mips_target_feature)]
136 #![feature(aarch64_target_feature)]
137 #![feature(wasm_target_feature)]
138 #![feature(avx512_target_feature)]
139 #![feature(cmpxchg16b_target_feature)]
140 #![feature(rtm_target_feature)]
141 #![feature(f16c_target_feature)]
142 #![feature(hexagon_target_feature)]
143 #![feature(const_fn_transmute)]
144 #![feature(abi_unadjusted)]
145 #![feature(adx_target_feature)]
146 #![feature(maybe_uninit_slice)]
147 #![feature(external_doc)]
148 #![feature(associated_type_bounds)]
149 #![feature(const_caller_location)]
150 #![feature(slice_ptr_get)]
151 #![feature(no_niche)] // rust-lang/rust#68303
152 #![feature(unsafe_block_in_unsafe_fn)]
153 #![deny(unsafe_op_in_unsafe_fn)]
159 #[cfg(not(test))] // See #65860
166 #[path = "num/int_macros.rs"]
170 #[path = "num/i128.rs"]
172 #[path = "num/i16.rs"]
174 #[path = "num/i32.rs"]
176 #[path = "num/i64.rs"]
178 #[path = "num/i8.rs"]
180 #[path = "num/isize.rs"]
183 #[path = "num/u128.rs"]
185 #[path = "num/u16.rs"]
187 #[path = "num/u32.rs"]
189 #[path = "num/u64.rs"]
191 #[path = "num/u8.rs"]
193 #[path = "num/usize.rs"]
196 #[path = "num/f32.rs"]
198 #[path = "num/f64.rs"]
204 /* The libcore prelude, not as all-encompassing as the libstd prelude */
208 /* Core modules for ownership management */
215 /* Core language traits */
218 #[cfg(not(test))] // See #65860
220 #[cfg(not(test))] // See #65860
223 #[cfg(not(test))] // See #65860
225 #[cfg(not(test))] // See #65860
229 /* Core types and methods on primitives */
232 #[cfg(not(test))] // See #65860
238 #[cfg(not(test))] // See #65860
240 #[unstable(feature = "once_cell", issue = "74465")]
245 #[cfg(not(test))] // See #65860
251 #[cfg(not(test))] // See #65860
253 #[cfg(not(test))] // See #65860
256 #[cfg(not(test))] // See #65860
263 #[cfg(not(test))] // See #65860
267 /* Heap memory allocator trait */
268 #[allow(missing_docs)]
271 // note: does not need to be public
276 #[stable(feature = "core_primitive", since = "1.43.0")]
279 // Pull in the `core_arch` crate directly into libcore. The contents of
280 // `core_arch` are in a different repository: rust-lang/stdarch.
282 // `core_arch` depends on libcore, but the contents of this module are
283 // set up in such a way that directly pulling it here works such that the
284 // crate uses the this crate as its libcore.
285 #[path = "../../stdarch/crates/core_arch/src/mod.rs"]
288 missing_debug_implementations,
291 unsafe_op_in_unsafe_fn
293 // FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
294 // merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
295 #[allow(clashing_extern_declarations)]
296 #[unstable(feature = "stdsimd", issue = "48556")]
299 #[stable(feature = "simd_arch", since = "1.27.0")]
300 pub use core_arch::arch;