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 "duplicate lang item found" error. See
48 // discussion in #50466 for details.
50 // This cfg won't affect doc tests.
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))))]
61 #![warn(deprecated_in_future)]
62 #![warn(missing_docs)]
63 #![warn(intra_doc_link_resolution_failure)]
64 #![warn(missing_debug_implementations)]
66 #![feature(allow_internal_unstable)]
67 #![feature(arbitrary_self_types)]
69 #![feature(associated_type_defaults)]
70 #![feature(cfg_target_has_atomic)]
71 #![feature(concat_idents)]
73 #![feature(const_fn_union)]
74 #![feature(custom_attribute)]
76 #![feature(doc_spotlight)]
77 #![feature(extern_types)]
78 #![feature(fundamental)]
79 #![feature(intrinsics)]
80 #![feature(is_sorted)]
81 #![feature(iter_once_with)]
82 #![feature(lang_items)]
83 #![feature(link_llvm_intrinsics)]
84 #![feature(never_type)]
86 #![feature(bind_by_move_pattern_guards)]
87 #![feature(exhaustive_patterns)]
89 #![feature(on_unimplemented)]
90 #![feature(optin_builtin_traits)]
91 #![feature(prelude_import)]
92 #![feature(repr_simd, platform_intrinsics)]
93 #![feature(rustc_attrs)]
94 #![feature(rustc_const_unstable)]
96 #![feature(specialization)]
97 #![feature(staged_api)]
98 #![feature(std_internals)]
99 #![feature(stmt_expr_attributes)]
100 #![feature(unboxed_closures)]
101 #![feature(unsized_locals)]
102 #![feature(untagged_unions)]
103 #![feature(unwind_attributes)]
104 #![feature(doc_alias)]
105 #![feature(mmx_target_feature)]
106 #![feature(tbm_target_feature)]
107 #![feature(sse4a_target_feature)]
108 #![feature(arm_target_feature)]
109 #![feature(powerpc_target_feature)]
110 #![feature(mips_target_feature)]
111 #![feature(aarch64_target_feature)]
112 #![feature(wasm_target_feature)]
113 #![feature(avx512_target_feature)]
114 #![feature(cmpxchg16b_target_feature)]
115 #![feature(const_slice_len)]
116 #![feature(const_str_as_bytes)]
117 #![feature(const_str_len)]
118 #![feature(const_int_conversion)]
119 #![feature(const_transmute)]
120 #![feature(reverse_bits)]
121 #![feature(non_exhaustive)]
122 #![feature(structural_match)]
123 #![feature(abi_unadjusted)]
124 #![feature(adx_target_feature)]
125 #![feature(maybe_uninit, maybe_uninit_slice, maybe_uninit_array)]
126 #![feature(external_doc)]
138 #[path = "num/int_macros.rs"]
142 #[path = "num/uint_macros.rs"]
146 #[path = "num/isize.rs"] pub mod isize;
147 #[path = "num/i8.rs"] pub mod i8;
148 #[path = "num/i16.rs"] pub mod i16;
149 #[path = "num/i32.rs"] pub mod i32;
150 #[path = "num/i64.rs"] pub mod i64;
151 #[path = "num/i128.rs"] pub mod i128;
153 #[path = "num/usize.rs"] pub mod usize;
154 #[path = "num/u8.rs"] pub mod u8;
155 #[path = "num/u16.rs"] pub mod u16;
156 #[path = "num/u32.rs"] pub mod u32;
157 #[path = "num/u64.rs"] pub mod u64;
158 #[path = "num/u128.rs"] pub mod u128;
160 #[path = "num/f32.rs"] pub mod f32;
161 #[path = "num/f64.rs"] pub mod f64;
166 /* The libcore prelude, not as all-encompassing as the libstd prelude */
170 /* Core modules for ownership management */
177 /* Core language traits */
187 /* Core types and methods on primitives */
216 /* Heap memory allocator trait */
217 #[allow(missing_docs)]
220 // note: does not need to be public
224 // Pull in the `core_arch` crate directly into libcore. The contents of
225 // `core_arch` are in a different repository: rust-lang-nursery/stdsimd.
227 // `core_arch` depends on libcore, but the contents of this module are
228 // set up in such a way that directly pulling it here works such that the
229 // crate uses the this crate as its libcore.
230 #[path = "../stdsimd/crates/core_arch/src/mod.rs"]
231 #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
232 #[unstable(feature = "stdsimd", issue = "48556")]
235 #[stable(feature = "simd_arch", since = "1.27.0")]
236 pub use core_arch::arch;