2014-05-22 09:44:54 -07:00
|
|
|
//! # The Rust Core Library
|
2014-05-12 21:22:35 -07:00
|
|
|
//!
|
2015-11-05 14:33:30 +01:00
|
|
|
//! The Rust Core Library is the dependency-free[^free] foundation of [The
|
2014-05-19 21:53:00 -07:00
|
|
|
//! Rust Standard Library](../std/index.html). It is the portable glue
|
|
|
|
//! between the language and its libraries, defining the intrinsic and
|
|
|
|
//! primitive building blocks of all Rust code. It links to no
|
2014-05-20 11:39:40 -07:00
|
|
|
//! upstream libraries, no system libraries, and no libc.
|
2014-05-19 21:53:00 -07:00
|
|
|
//!
|
2015-11-05 14:33:30 +01:00
|
|
|
//! [^free]: Strictly speaking, there are some symbols which are needed but
|
2015-11-18 11:35:29 +01:00
|
|
|
//! they aren't always necessary.
|
2015-11-05 14:33:30 +01:00
|
|
|
//!
|
2014-05-19 21:53:00 -07:00
|
|
|
//! The core library is *minimal*: it isn't even aware of heap allocation,
|
|
|
|
//! nor does it provide concurrency or I/O. These things require
|
2014-05-20 11:39:40 -07:00
|
|
|
//! platform integration, and this library is platform-agnostic.
|
2014-05-19 21:53:00 -07:00
|
|
|
//!
|
|
|
|
//! # How to use the core library
|
|
|
|
//!
|
2016-07-15 13:17:35 -04:00
|
|
|
//! Please note that all of these details are currently not considered stable.
|
|
|
|
//!
|
2014-05-20 10:40:14 -07:00
|
|
|
// FIXME: Fill me in with more detail when the interface settles
|
2014-05-19 21:53:00 -07:00
|
|
|
//! This library is built on the assumption of a few existing symbols:
|
2014-05-12 21:22:35 -07:00
|
|
|
//!
|
|
|
|
//! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
|
|
|
|
//! often generated by LLVM. Additionally, this library can make explicit
|
2014-05-20 00:51:16 +09:00
|
|
|
//! calls to these functions. Their signatures are the same as found in C.
|
2014-05-14 11:24:12 -07:00
|
|
|
//! These functions are often provided by the system libc, but can also be
|
2019-01-02 15:18:13 +08:00
|
|
|
//! provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins).
|
2014-05-12 21:22:35 -07:00
|
|
|
//!
|
2017-06-28 02:41:24 +02:00
|
|
|
//! * `rust_begin_panic` - This function takes four arguments, a
|
|
|
|
//! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments
|
2016-07-15 13:17:35 -04:00
|
|
|
//! dictate the panic message, the file at which panic was invoked, and the
|
2017-06-27 04:26:52 +02:00
|
|
|
//! line and column inside the file. It is up to consumers of this core
|
|
|
|
//! library to define this panic function; it is only required to never
|
2018-04-30 10:57:11 +02:00
|
|
|
//! return. This requires a `lang` attribute named `panic_impl`.
|
2016-08-14 13:33:53 +02:00
|
|
|
//!
|
|
|
|
//! * `rust_eh_personality` - is used by the failure mechanisms of the
|
|
|
|
//! compiler. This is often mapped to GCC's personality function, but crates
|
|
|
|
//! which do not trigger a panic can be assured that this function is never
|
|
|
|
//! called. The `lang` attribute is called `eh_personality`.
|
2014-06-28 13:57:36 -07:00
|
|
|
|
|
|
|
// Since libcore defines many fundamental lang items, all tests live in a
|
|
|
|
// separate crate, libcoretest, to avoid bizarre issues.
|
2018-05-06 03:29:19 +08:00
|
|
|
//
|
|
|
|
// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
|
|
|
|
// this, both the generated test artifact and the linked libtest (which
|
|
|
|
// transitively includes libcore) will both define the same set of lang items,
|
2020-01-10 14:36:22 +00:00
|
|
|
// and this will cause the E0152 "found duplicate lang item" error. See
|
2018-05-06 03:29:19 +08:00
|
|
|
// discussion in #50466 for details.
|
|
|
|
//
|
|
|
|
// This cfg won't affect doc tests.
|
2018-05-06 01:02:05 +08:00
|
|
|
#![cfg(not(test))]
|
2015-12-02 17:31:49 -08:00
|
|
|
#![stable(feature = "core", since = "1.6.0")]
|
2019-12-22 17:42:04 -05:00
|
|
|
#![doc(
|
|
|
|
html_root_url = "https://doc.rust-lang.org/nightly/",
|
|
|
|
html_playground_url = "https://play.rust-lang.org/",
|
|
|
|
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
|
|
|
test(no_crate_inject, attr(deny(warnings))),
|
|
|
|
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
|
|
|
|
)]
|
2015-08-11 14:31:23 -07:00
|
|
|
#![no_core]
|
2018-12-21 11:08:26 +01:00
|
|
|
#![warn(deprecated_in_future)]
|
2019-01-28 10:49:11 +01:00
|
|
|
#![warn(missing_docs)]
|
|
|
|
#![warn(missing_debug_implementations)]
|
2019-04-14 10:00:09 +02:00
|
|
|
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
|
2019-04-15 11:23:21 +09:00
|
|
|
#![allow(explicit_outlives_requirements)]
|
2019-08-11 12:55:14 -04:00
|
|
|
#![allow(incomplete_features)]
|
2015-08-11 14:31:23 -07:00
|
|
|
#![feature(allow_internal_unstable)]
|
2018-05-22 17:07:51 -07:00
|
|
|
#![feature(arbitrary_self_types)]
|
2016-05-04 16:08:21 +02:00
|
|
|
#![feature(asm)]
|
2019-05-31 21:17:32 -05:00
|
|
|
#![feature(bound_cloned)]
|
2017-03-17 15:05:44 +01:00
|
|
|
#![feature(cfg_target_has_atomic)]
|
2015-08-11 14:31:23 -07:00
|
|
|
#![feature(concat_idents)]
|
2020-02-08 21:29:16 -08:00
|
|
|
#![feature(const_ascii_ctype_on_intrinsics)]
|
2020-01-01 00:25:20 +01:00
|
|
|
#![feature(const_alloc_layout)]
|
2020-03-08 14:24:32 +01:00
|
|
|
#![feature(const_discriminant)]
|
2019-12-27 11:59:55 +10:00
|
|
|
#![feature(const_if_match)]
|
2020-02-08 16:32:30 -08:00
|
|
|
#![feature(const_loop)]
|
2020-02-04 11:46:03 -08:00
|
|
|
#![feature(const_checked_int_methods)]
|
|
|
|
#![feature(const_euclidean_int_methods)]
|
|
|
|
#![feature(const_overflowing_int_methods)]
|
|
|
|
#![feature(const_saturating_int_methods)]
|
2020-02-03 12:49:31 -08:00
|
|
|
#![feature(const_int_unchecked_arith)]
|
2020-02-08 16:32:30 -08:00
|
|
|
#![feature(const_int_pow)]
|
|
|
|
#![feature(constctlz)]
|
2019-12-27 11:59:55 +10:00
|
|
|
#![feature(const_panic)]
|
2018-07-02 19:00:07 +02:00
|
|
|
#![feature(const_fn_union)]
|
2019-07-25 18:06:26 +02:00
|
|
|
#![feature(const_generics)]
|
2020-04-24 00:19:11 -07:00
|
|
|
#![feature(const_ptr_offset)]
|
2019-12-18 12:00:59 -05:00
|
|
|
#![feature(const_ptr_offset_from)]
|
2019-12-28 21:33:36 +01:00
|
|
|
#![feature(const_result)]
|
2020-05-06 07:43:18 +02:00
|
|
|
#![feature(const_slice_from_raw_parts)]
|
|
|
|
#![feature(const_slice_ptr_len)]
|
2019-12-18 12:00:59 -05:00
|
|
|
#![feature(const_type_name)]
|
2019-06-29 14:06:22 +03:00
|
|
|
#![feature(custom_inner_attributes)]
|
2019-06-29 17:51:20 +03:00
|
|
|
#![feature(decl_macro)]
|
2018-03-09 11:31:04 -08:00
|
|
|
#![feature(doc_cfg)]
|
2018-04-02 11:26:16 +02:00
|
|
|
#![feature(extern_types)]
|
2015-08-11 14:31:23 -07:00
|
|
|
#![feature(fundamental)]
|
2015-06-09 11:18:03 -07:00
|
|
|
#![feature(intrinsics)]
|
2019-08-06 14:13:13 +03:00
|
|
|
#![feature(try_find)]
|
2018-10-11 09:53:15 -07:00
|
|
|
#![feature(is_sorted)]
|
2015-06-09 11:18:03 -07:00
|
|
|
#![feature(lang_items)]
|
2018-02-17 17:23:19 -08:00
|
|
|
#![feature(link_llvm_intrinsics)]
|
2020-01-14 13:40:42 +00:00
|
|
|
#![feature(llvm_asm)]
|
2020-04-22 15:45:35 -04:00
|
|
|
#![feature(negative_impls)]
|
2019-12-11 09:55:29 -05:00
|
|
|
#![feature(never_type)]
|
2018-09-26 14:26:46 -07:00
|
|
|
#![feature(nll)]
|
2018-01-21 16:44:41 +08:00
|
|
|
#![feature(exhaustive_patterns)]
|
2015-08-11 14:31:23 -07:00
|
|
|
#![feature(no_core)]
|
|
|
|
#![feature(optin_builtin_traits)]
|
2020-04-16 12:44:57 -07:00
|
|
|
#![feature(or_patterns)]
|
2017-03-17 15:05:44 +01:00
|
|
|
#![feature(prelude_import)]
|
2015-12-11 13:07:11 -08:00
|
|
|
#![feature(repr_simd, platform_intrinsics)]
|
2016-03-10 21:20:09 +02:00
|
|
|
#![feature(rustc_attrs)]
|
2018-02-17 17:23:19 -08:00
|
|
|
#![feature(simd_ffi)]
|
2016-04-05 14:06:20 +02:00
|
|
|
#![feature(specialization)]
|
2015-01-30 12:26:44 -08:00
|
|
|
#![feature(staged_api)]
|
2019-02-01 12:43:29 +01:00
|
|
|
#![feature(std_internals)]
|
2018-02-17 17:23:19 -08:00
|
|
|
#![feature(stmt_expr_attributes)]
|
2019-12-18 12:00:59 -05:00
|
|
|
#![feature(track_caller)]
|
2019-07-04 10:05:50 -04:00
|
|
|
#![feature(transparent_unions)]
|
2015-01-06 09:24:46 -08:00
|
|
|
#![feature(unboxed_closures)]
|
2018-11-08 15:28:06 +01:00
|
|
|
#![feature(unsized_locals)]
|
2017-03-17 15:05:44 +01:00
|
|
|
#![feature(untagged_unions)]
|
|
|
|
#![feature(unwind_attributes)]
|
2018-04-19 19:56:10 +02:00
|
|
|
#![feature(doc_alias)]
|
2018-05-10 12:02:19 -06:00
|
|
|
#![feature(mmx_target_feature)]
|
|
|
|
#![feature(tbm_target_feature)]
|
|
|
|
#![feature(sse4a_target_feature)]
|
|
|
|
#![feature(arm_target_feature)]
|
|
|
|
#![feature(powerpc_target_feature)]
|
|
|
|
#![feature(mips_target_feature)]
|
|
|
|
#![feature(aarch64_target_feature)]
|
2018-08-15 10:51:24 -07:00
|
|
|
#![feature(wasm_target_feature)]
|
2018-12-17 12:06:06 -08:00
|
|
|
#![feature(avx512_target_feature)]
|
2019-01-19 16:25:06 -07:00
|
|
|
#![feature(cmpxchg16b_target_feature)]
|
2019-07-15 13:57:34 +02:00
|
|
|
#![feature(rtm_target_feature)]
|
|
|
|
#![feature(f16c_target_feature)]
|
2018-08-10 12:01:18 -05:00
|
|
|
#![feature(hexagon_target_feature)]
|
2018-09-01 15:05:55 +02:00
|
|
|
#![feature(const_transmute)]
|
2019-01-07 16:20:25 +01:00
|
|
|
#![feature(abi_unadjusted)]
|
2019-01-19 16:25:06 -07:00
|
|
|
#![feature(adx_target_feature)]
|
2019-08-11 12:55:14 -04:00
|
|
|
#![feature(maybe_uninit_slice)]
|
2019-02-11 15:29:25 +01:00
|
|
|
#![feature(external_doc)]
|
2019-07-31 21:00:35 +02:00
|
|
|
#![feature(associated_type_bounds)]
|
2019-12-20 23:15:50 +01:00
|
|
|
#![feature(const_type_id)]
|
|
|
|
#![feature(const_caller_location)]
|
2020-03-15 19:43:25 +01:00
|
|
|
#![feature(no_niche)] // rust-lang/rust#68303
|
2018-04-03 11:11:49 -07:00
|
|
|
|
2016-08-22 10:02:28 +00:00
|
|
|
#[prelude_import]
|
|
|
|
#[allow(unused)]
|
|
|
|
use prelude::v1::*;
|
2014-05-01 18:06:59 -07:00
|
|
|
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2015-01-06 09:24:46 -08:00
|
|
|
#[macro_use]
|
2014-05-01 10:47:18 -07:00
|
|
|
mod macros;
|
|
|
|
|
2016-10-23 14:27:49 +01:00
|
|
|
#[macro_use]
|
|
|
|
mod internal_macros;
|
|
|
|
|
2014-12-18 20:09:57 -08:00
|
|
|
#[path = "num/int_macros.rs"]
|
2015-01-06 09:24:46 -08:00
|
|
|
#[macro_use]
|
2014-12-18 20:09:57 -08:00
|
|
|
mod int_macros;
|
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
#[path = "num/i128.rs"]
|
|
|
|
pub mod i128;
|
|
|
|
#[path = "num/i16.rs"]
|
|
|
|
pub mod i16;
|
|
|
|
#[path = "num/i32.rs"]
|
|
|
|
pub mod i32;
|
|
|
|
#[path = "num/i64.rs"]
|
|
|
|
pub mod i64;
|
|
|
|
#[path = "num/i8.rs"]
|
|
|
|
pub mod i8;
|
|
|
|
#[path = "num/isize.rs"]
|
|
|
|
pub mod isize;
|
2016-08-23 03:56:52 +03:00
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
#[path = "num/u128.rs"]
|
|
|
|
pub mod u128;
|
|
|
|
#[path = "num/u16.rs"]
|
|
|
|
pub mod u16;
|
|
|
|
#[path = "num/u32.rs"]
|
|
|
|
pub mod u32;
|
|
|
|
#[path = "num/u64.rs"]
|
|
|
|
pub mod u64;
|
|
|
|
#[path = "num/u8.rs"]
|
|
|
|
pub mod u8;
|
|
|
|
#[path = "num/usize.rs"]
|
|
|
|
pub mod usize;
|
2016-08-23 03:56:52 +03:00
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
#[path = "num/f32.rs"]
|
|
|
|
pub mod f32;
|
|
|
|
#[path = "num/f64.rs"]
|
|
|
|
pub mod f64;
|
2014-04-30 22:23:26 -07:00
|
|
|
|
2015-04-17 23:45:55 -07:00
|
|
|
#[macro_use]
|
2014-04-30 22:14:22 -07:00
|
|
|
pub mod num;
|
|
|
|
|
2014-05-01 18:06:59 -07:00
|
|
|
/* The libcore prelude, not as all-encompassing as the libstd prelude */
|
|
|
|
|
|
|
|
pub mod prelude;
|
|
|
|
|
2014-04-30 20:04:56 -07:00
|
|
|
/* Core modules for ownership management */
|
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod hint;
|
2014-04-30 20:04:56 -07:00
|
|
|
pub mod intrinsics;
|
2014-04-30 20:13:05 -07:00
|
|
|
pub mod mem;
|
2014-04-30 20:17:50 -07:00
|
|
|
pub mod ptr;
|
2014-04-30 20:22:55 -07:00
|
|
|
|
|
|
|
/* Core language traits */
|
|
|
|
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod borrow;
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod clone;
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2014-06-28 13:57:36 -07:00
|
|
|
pub mod cmp;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod convert;
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2014-04-30 20:46:51 -07:00
|
|
|
pub mod default;
|
2019-12-22 17:42:04 -05:00
|
|
|
#[cfg(not(test))] // See #65860
|
|
|
|
pub mod marker;
|
|
|
|
pub mod ops;
|
2014-04-30 20:33:08 -07:00
|
|
|
|
|
|
|
/* Core types and methods on primitives */
|
|
|
|
|
2014-04-30 20:36:58 -07:00
|
|
|
pub mod any;
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2015-02-27 22:48:51 +03:00
|
|
|
pub mod array;
|
2018-03-04 13:44:43 -05:00
|
|
|
pub mod ascii;
|
2014-05-01 11:19:56 -07:00
|
|
|
pub mod cell;
|
|
|
|
pub mod char;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod ffi;
|
|
|
|
#[cfg(not(test))] // See #65860
|
|
|
|
pub mod iter;
|
|
|
|
pub mod option;
|
2018-01-23 16:31:53 +01:00
|
|
|
pub mod panic;
|
2014-10-09 15:17:22 -04:00
|
|
|
pub mod panicking;
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2018-08-09 18:20:22 +03:00
|
|
|
pub mod pin;
|
2014-04-30 20:38:31 -07:00
|
|
|
pub mod raw;
|
2014-04-30 23:25:35 -07:00
|
|
|
pub mod result;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod sync;
|
2015-07-13 11:57:46 -07:00
|
|
|
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod fmt;
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2014-12-12 18:43:07 -08:00
|
|
|
pub mod hash;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod slice;
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod str;
|
2017-12-11 13:42:01 -05:00
|
|
|
pub mod time;
|
2014-04-30 23:19:52 -07:00
|
|
|
|
2018-04-05 17:09:28 +02:00
|
|
|
pub mod unicode;
|
|
|
|
|
2018-05-30 18:23:10 -07:00
|
|
|
/* Async */
|
2019-10-30 20:59:15 +01:00
|
|
|
#[cfg(not(test))] // See #65860
|
2018-05-30 18:23:10 -07:00
|
|
|
pub mod future;
|
|
|
|
pub mod task;
|
|
|
|
|
2018-03-28 22:37:37 +02:00
|
|
|
/* Heap memory allocator trait */
|
|
|
|
#[allow(missing_docs)]
|
2018-04-03 14:41:15 +02:00
|
|
|
pub mod alloc;
|
|
|
|
|
2014-10-31 05:41:25 -04:00
|
|
|
// note: does not need to be public
|
2019-09-07 17:04:19 +01:00
|
|
|
mod bool;
|
2014-12-18 19:13:32 -08:00
|
|
|
mod tuple;
|
2017-10-18 23:12:37 -07:00
|
|
|
mod unit;
|
2018-02-17 17:23:19 -08:00
|
|
|
|
2020-02-23 23:59:39 -08:00
|
|
|
#[stable(feature = "core_primitive", since = "1.43.0")]
|
2019-12-26 12:55:13 -05:00
|
|
|
pub mod primitive;
|
|
|
|
|
2019-01-21 18:42:04 +01:00
|
|
|
// Pull in the `core_arch` crate directly into libcore. The contents of
|
2019-07-15 13:53:44 +02:00
|
|
|
// `core_arch` are in a different repository: rust-lang/stdarch.
|
2019-01-21 18:42:04 +01:00
|
|
|
//
|
|
|
|
// `core_arch` depends on libcore, but the contents of this module are
|
|
|
|
// set up in such a way that directly pulling it here works such that the
|
|
|
|
// crate uses the this crate as its libcore.
|
2019-07-15 13:53:44 +02:00
|
|
|
#[path = "../stdarch/crates/core_arch/src/mod.rs"]
|
2018-04-07 19:38:35 +02:00
|
|
|
#[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
|
2018-02-17 17:23:19 -08:00
|
|
|
#[unstable(feature = "stdsimd", issue = "48556")]
|
2019-01-21 18:42:04 +01:00
|
|
|
mod core_arch;
|
2018-02-17 17:23:19 -08:00
|
|
|
|
2018-04-03 11:11:49 -07:00
|
|
|
#[stable(feature = "simd_arch", since = "1.27.0")]
|
2019-01-21 18:42:04 +01:00
|
|
|
pub use core_arch::arch;
|