]> git.proxmox.com Git - rustc.git/blame - src/libcore/lib.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / src / libcore / lib.rs
CommitLineData
1a4d82fc
JJ
1//! # The Rust Core Library
2//!
92a42be0 3//! The Rust Core Library is the dependency-free[^free] foundation of [The
1a4d82fc
JJ
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//!
92a42be0
SL
9//! [^free]: Strictly speaking, there are some symbols which are needed but
10//! they aren't always necessary.
11//!
1a4d82fc
JJ
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//!
1a4d82fc
JJ
16//! # How to use the core library
17//!
5bcae85e
SL
18//! Please note that all of these details are currently not considered stable.
19//!
1a4d82fc
JJ
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
c34b1796 27//! provided by the [rlibc crate](https://crates.io/crates/rlibc).
1a4d82fc 28//!
041b39d2
XL
29//! * `rust_begin_panic` - This function takes four arguments, a
30//! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments
5bcae85e 31//! dictate the panic message, the file at which panic was invoked, and the
041b39d2
XL
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
94b46f34 34//! return. This requires a `lang` attribute named `panic_impl`.
9e0c209e
SL
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`.
1a4d82fc
JJ
40
41// Since libcore defines many fundamental lang items, all tests live in a
42// separate crate, libcoretest, to avoid bizarre issues.
83c7162d
XL
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))]
1a4d82fc 52
92a42be0 53#![stable(feature = "core", since = "1.6.0")]
e9174d1e 54#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
62682a34 55 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
e9174d1e
SL
56 html_root_url = "https://doc.rust-lang.org/nightly/",
57 html_playground_url = "https://play.rust-lang.org/",
92a42be0
SL
58 issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
59 test(no_crate_inject, attr(deny(warnings))),
60 test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
1a4d82fc 61
e9174d1e 62#![no_core]
1a4d82fc 63#![deny(missing_docs)]
0731742a 64#![deny(intra_doc_link_resolution_failure)]
54a0048b 65#![deny(missing_debug_implementations)]
1a4d82fc 66
e9174d1e 67#![feature(allow_internal_unstable)]
94b46f34 68#![feature(arbitrary_self_types)]
a7813a04 69#![feature(asm)]
62682a34 70#![feature(associated_type_defaults)]
cc61c64b 71#![feature(cfg_target_has_atomic)]
e9174d1e
SL
72#![feature(concat_idents)]
73#![feature(const_fn)]
0731742a 74#![cfg_attr(stage0, feature(const_int_ops))]
b7449926 75#![feature(const_fn_union)]
e9174d1e 76#![feature(custom_attribute)]
0531ce1d
XL
77#![feature(doc_cfg)]
78#![feature(doc_spotlight)]
83c7162d 79#![feature(extern_types)]
e9174d1e 80#![feature(fundamental)]
62682a34 81#![feature(intrinsics)]
0731742a 82#![feature(iter_once_with)]
62682a34 83#![feature(lang_items)]
0531ce1d 84#![feature(link_llvm_intrinsics)]
cc61c64b 85#![feature(never_type)]
0bf4aa26 86#![feature(nll)]
0731742a 87#![feature(bind_by_move_pattern_guards)]
0531ce1d 88#![feature(exhaustive_patterns)]
e9174d1e 89#![feature(no_core)]
85aaf69f 90#![feature(on_unimplemented)]
c34b1796 91#![feature(optin_builtin_traits)]
cc61c64b 92#![feature(prelude_import)]
9cc50fc6 93#![feature(repr_simd, platform_intrinsics)]
54a0048b 94#![feature(rustc_attrs)]
0531ce1d
XL
95#![feature(rustc_const_unstable)]
96#![feature(simd_ffi)]
54a0048b 97#![feature(specialization)]
e9174d1e 98#![feature(staged_api)]
0531ce1d 99#![feature(stmt_expr_attributes)]
e9174d1e 100#![feature(unboxed_closures)]
a1dfa0c6 101#![feature(unsized_locals)]
cc61c64b
XL
102#![feature(untagged_unions)]
103#![feature(unwind_attributes)]
83c7162d 104#![feature(doc_alias)]
94b46f34
XL
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)]
0bf4aa26 112#![feature(wasm_target_feature)]
0731742a
XL
113#![feature(avx512_target_feature)]
114#![cfg_attr(not(stage0), feature(cmpxchg16b_target_feature))]
94b46f34
XL
115#![feature(const_slice_len)]
116#![feature(const_str_as_bytes)]
117#![feature(const_str_len)]
0731742a
XL
118#![cfg_attr(stage0, feature(const_let))]
119#![cfg_attr(stage0, feature(const_int_rotate))]
b7449926
XL
120#![feature(const_int_conversion)]
121#![feature(const_transmute)]
122#![feature(reverse_bits)]
123#![feature(non_exhaustive)]
a1dfa0c6 124#![feature(structural_match)]
0731742a
XL
125#![feature(abi_unadjusted)]
126#![cfg_attr(not(stage0), feature(adx_target_feature))]
ea8adc8c 127
9e0c209e
SL
128#[prelude_import]
129#[allow(unused)]
130use prelude::v1::*;
5bcae85e 131
1a4d82fc
JJ
132#[macro_use]
133mod macros;
134
c30ab7b3
SL
135#[macro_use]
136mod internal_macros;
137
1a4d82fc
JJ
138#[path = "num/int_macros.rs"]
139#[macro_use]
140mod int_macros;
141
142#[path = "num/uint_macros.rs"]
143#[macro_use]
144mod uint_macros;
145
5bcae85e
SL
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;
94b46f34 151#[path = "num/i128.rs"] pub mod i128;
32a655c1 152
1a4d82fc 153#[path = "num/usize.rs"] pub mod usize;
5bcae85e
SL
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;
94b46f34 158#[path = "num/u128.rs"] pub mod u128;
32a655c1 159
1a4d82fc
JJ
160#[path = "num/f32.rs"] pub mod f32;
161#[path = "num/f64.rs"] pub mod f64;
162
9346a6ac 163#[macro_use]
1a4d82fc
JJ
164pub mod num;
165
166/* The libcore prelude, not as all-encompassing as the libstd prelude */
167
168pub mod prelude;
169
170/* Core modules for ownership management */
171
172pub mod intrinsics;
173pub mod mem;
1a4d82fc 174pub mod ptr;
83c7162d 175pub mod hint;
1a4d82fc
JJ
176
177/* Core language traits */
178
179pub mod marker;
180pub mod ops;
181pub mod cmp;
182pub mod clone;
183pub mod default;
c34b1796 184pub mod convert;
e9174d1e 185pub mod borrow;
1a4d82fc
JJ
186
187/* Core types and methods on primitives */
188
189pub mod any;
c34b1796 190pub mod array;
0531ce1d 191pub mod ascii;
e9174d1e 192pub mod sync;
1a4d82fc
JJ
193pub mod cell;
194pub mod char;
0531ce1d 195pub mod panic;
1a4d82fc 196pub mod panicking;
b7449926 197pub mod pin;
1a4d82fc
JJ
198pub mod iter;
199pub mod option;
200pub mod raw;
201pub mod result;
b7449926 202pub mod ffi;
e9174d1e 203
1a4d82fc
JJ
204pub mod slice;
205pub mod str;
206pub mod hash;
207pub mod fmt;
2c00a5a8 208pub mod time;
85aaf69f 209
83c7162d
XL
210pub mod unicode;
211
94b46f34
XL
212/* Async */
213pub mod future;
214pub mod task;
215
0531ce1d
XL
216/* Heap memory allocator trait */
217#[allow(missing_docs)]
83c7162d
XL
218pub mod alloc;
219
1a4d82fc 220// note: does not need to be public
3157f602 221mod iter_private;
1a4d82fc 222mod tuple;
abe05a73 223mod unit;
0531ce1d 224
a1dfa0c6 225// Pull in the `coresimd` crate directly into libcore. This is where all the
0531ce1d
XL
226// architecture-specific (and vendor-specific) intrinsics are defined. AKA
227// things like SIMD and such. Note that the actual source for all this lies in a
228// different repository, rust-lang-nursery/stdsimd. That's why the setup here is
229// a bit wonky.
83c7162d
XL
230#[allow(unused_macros)]
231macro_rules! test_v16 { ($item:item) => {}; }
232#[allow(unused_macros)]
233macro_rules! test_v32 { ($item:item) => {}; }
234#[allow(unused_macros)]
235macro_rules! test_v64 { ($item:item) => {}; }
236#[allow(unused_macros)]
237macro_rules! test_v128 { ($item:item) => {}; }
238#[allow(unused_macros)]
239macro_rules! test_v256 { ($item:item) => {}; }
240#[allow(unused_macros)]
241macro_rules! test_v512 { ($item:item) => {}; }
242#[allow(unused_macros)]
243macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } }
0531ce1d 244#[path = "../stdsimd/coresimd/mod.rs"]
83c7162d 245#[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
0531ce1d 246#[unstable(feature = "stdsimd", issue = "48556")]
0531ce1d
XL
247mod coresimd;
248
83c7162d 249#[stable(feature = "simd_arch", since = "1.27.0")]
0531ce1d 250pub use coresimd::arch;