rust/library/core/src/lib.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

456 lines
14 KiB
Rust
Raw Normal View History

2014-05-22 09:44:54 -07:00
//! # The Rust Core Library
2014-05-12 21:22:35 -07: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
//!
//! [^free]: Strictly speaking, there are some symbols which are needed but
2015-11-18 11:35:29 +01:00
//! they aren't always necessary.
//!
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
//!
//! 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`, `memmove`, `memset`, `memcmp`, `bcmp`, `strlen` - These are core memory routines
//! which are generated by Rust codegen backends. Additionally, this library can make explicit
//! calls to `strlen`. Their signatures are the same as found in C, but there are extra
//! assumptions about their semantics: For `memcpy`, `memmove`, `memset`, `memcmp`, and `bcmp`, if
//! the `n` parameter is 0, the function is assumed to not be UB, even if the pointers are NULL or
//! dangling. (Note that making extra assumptions about these functions is common among compilers:
2023-11-24 11:15:53 +01:00
//! [clang](https://reviews.llvm.org/D86993) and [GCC](https://gcc.gnu.org/onlinedocs/gcc/Standards.html#C-Language) do the same.)
//! These functions are often provided by the system libc, but can also be provided by the
//! [compiler-builtins crate](https://crates.io/crates/compiler_builtins).
//! Note that the library does not guarantee that it will always make these assumptions, so Rust
//! user code directly calling the C functions should follow the C specification! The advice for
//! Rust user code is to call the functions provided by this library instead (such as
//! `ptr::copy`).
2014-05-12 21:22:35 -07:00
//!
//! * Panic handler - This function takes one argument, a `&panic::PanicInfo`. It is up to consumers of this core
2017-06-27 04:26:52 +02:00
//! library to define this panic function; it is only required to never
//! return. You should mark your implementation using `#[panic_handler]`.
//!
//! * `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`.
// Since core defines many fundamental lang items, all tests live in a
2022-11-03 15:59:23 -07:00
// separate crate, libcoretest (library/core/tests), 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 core) will both define the same set of lang items,
// 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.
#![cfg(not(test))]
//
std: Stabilize APIs for the 1.6 release This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2015-12-02 17:31:49 -08:00
#![stable(feature = "core", since = "1.6.0")]
#![doc(
html_playground_url = "https://play.rust-lang.org/",
std: Stabilize APIs for the 1.6 release This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2015-12-02 17:31:49 -08:00
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)))
)]
2023-11-13 07:39:17 -05:00
#![doc(rust_logo)]
2022-01-14 09:50:49 +01:00
#![doc(cfg_hide(
not(test),
no_fp_fmt_parse,
target_pointer_width = "16",
target_pointer_width = "32",
target_pointer_width = "64",
target_has_atomic = "8",
target_has_atomic = "16",
target_has_atomic = "32",
target_has_atomic = "64",
target_has_atomic = "ptr",
target_has_atomic_equal_alignment = "8",
target_has_atomic_equal_alignment = "16",
target_has_atomic_equal_alignment = "32",
target_has_atomic_equal_alignment = "64",
target_has_atomic_equal_alignment = "ptr",
target_has_atomic_load_store = "8",
target_has_atomic_load_store = "16",
target_has_atomic_load_store = "32",
target_has_atomic_load_store = "64",
target_has_atomic_load_store = "ptr",
))]
#![no_core]
2022-04-05 22:42:23 +02:00
#![rustc_coherence_is_core]
2024-04-29 09:27:34 -04:00
#![rustc_preserve_ub_checks]
2021-08-04 18:24:57 +02:00
//
// Lints:
#![deny(rust_2021_incompatible_or_patterns)]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(fuzzy_provenance_casts)]
#![warn(deprecated_in_future)]
#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
2019-04-15 11:23:21 +09:00
#![allow(explicit_outlives_requirements)]
#![allow(incomplete_features)]
2023-03-07 08:39:30 -05:00
#![warn(multiple_supertrait_upcastable)]
2023-08-22 07:06:38 -04:00
#![allow(internal_features)]
#![deny(ffi_unwind_calls)]
2023-07-03 10:30:29 +08:00
// Do not check link redundancy on bootstraping phase
2023-08-22 07:06:38 -04:00
#![allow(rustdoc::redundant_explicit_links)]
#![warn(rustdoc::unescaped_backticks)]
2021-08-04 18:24:57 +02:00
//
2022-03-07 16:36:13 -05:00
// Library features:
// tidy-alphabetical-start
Re-do recursive const stability checks Fundamentally, we have *three* disjoint categories of functions: 1. const-stable functions 2. private/unstable functions that are meant to be callable from const-stable functions 3. functions that can make use of unstable const features This PR implements the following system: - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions. - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category. - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls. Also, several holes in recursive const stability checking are being closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to *not* be `rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine. The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability. Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
2024-10-06 19:59:19 +02:00
#![cfg_attr(bootstrap, feature(const_fmt_arguments_new))]
#![feature(array_ptr_get)]
2024-04-11 16:26:02 -07:00
#![feature(asm_experimental_arch)]
#![feature(const_align_of_val)]
#![feature(const_align_of_val_raw)]
#![feature(const_align_offset)]
#![feature(const_alloc_layout)]
2021-12-23 20:07:41 +09:00
#![feature(const_black_box)]
#![feature(const_char_encode_utf16)]
#![feature(const_eval_select)]
2022-10-07 20:57:34 +02:00
#![feature(const_exact_div)]
#![feature(const_float_methods)]
#![feature(const_heap)]
#![feature(const_nonnull_new)]
2021-12-15 01:58:01 +08:00
#![feature(const_option_ext)]
2024-09-09 08:43:03 +01:00
#![feature(const_pin_2)]
2022-10-07 22:24:31 +02:00
#![feature(const_pointer_is_aligned)]
2021-12-12 04:27:43 +09:00
#![feature(const_ptr_is_null)]
#![feature(const_ptr_sub_ptr)]
2020-07-16 09:12:59 -04:00
#![feature(const_raw_ptr_comparison)]
#![feature(const_size_of_val)]
#![feature(const_size_of_val_raw)]
#![feature(const_sockaddr_setters)]
#![feature(const_swap)]
2022-09-10 07:44:56 +00:00
#![feature(const_try)]
#![feature(const_type_id)]
2019-12-18 12:00:59 -05:00
#![feature(const_type_name)]
#![feature(const_typed_swap)]
#![feature(const_ub_checks)]
#![feature(const_unicode_case_lookup)]
Re-do recursive const stability checks Fundamentally, we have *three* disjoint categories of functions: 1. const-stable functions 2. private/unstable functions that are meant to be callable from const-stable functions 3. functions that can make use of unstable const features This PR implements the following system: - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions. - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category. - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls. Also, several holes in recursive const stability checking are being closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to *not* be `rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine. The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability. Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
2024-10-06 19:59:19 +02:00
#![feature(core_intrinsics)]
2023-10-03 22:27:25 -04:00
#![feature(coverage_attribute)]
#![feature(do_not_recommend)]
#![feature(internal_impls_macro)]
#![feature(ip)]
#![feature(is_ascii_octdigit)]
#![feature(is_val_statically_known)]
#![feature(lazy_get)]
2024-03-10 04:57:45 +00:00
#![feature(link_cfg)]
#![feature(non_null_from_ref)]
#![feature(offset_of_enum)]
#![feature(panic_internals)]
#![feature(ptr_alignment_type)]
#![feature(ptr_metadata)]
#![feature(set_ptr_value)]
Re-do recursive const stability checks Fundamentally, we have *three* disjoint categories of functions: 1. const-stable functions 2. private/unstable functions that are meant to be callable from const-stable functions 3. functions that can make use of unstable const features This PR implements the following system: - `#[rustc_const_stable]` puts functions in the first category. It may only be applied to `#[stable]` functions. - `#[rustc_const_unstable]` by default puts functions in the third category. The new attribute `#[rustc_const_stable_indirect]` can be added to such a function to move it into the second category. - `const fn` without a const stability marker are in the second category if they are still unstable. They automatically inherit the feature gate for regular calls, it can now also be used for const-calls. Also, several holes in recursive const stability checking are being closed. There's still one potential hole that is hard to avoid, which is when MIR building automatically inserts calls to a particular function in stable functions -- which happens in the panic machinery. Those need to *not* be `rustc_const_unstable` (or manually get a `rustc_const_stable_indirect`) to be sure they follow recursive const stability. But that's a fairly rare and special case so IMO it's fine. The net effect of this is that a `#[unstable]` or unmarked function can be constified simply by marking it as `const fn`, and it will then be const-callable from stable `const fn` and subject to recursive const stability requirements. If it is publicly reachable (which implies it cannot be unmarked), it will be const-unstable under the same feature gate. Only if the function ever becomes `#[stable]` does it need a `#[rustc_const_unstable]` or `#[rustc_const_stable]` marker to decide if this should also imply const-stability. Adding `#[rustc_const_unstable]` is only needed for (a) functions that need to use unstable const lang features (including intrinsics), or (b) `#[stable]` functions that are not yet intended to be const-stable. Adding `#[rustc_const_stable]` is only needed for functions that are actually meant to be directly callable from stable const code. `#[rustc_const_stable_indirect]` is used to mark intrinsics as const-callable and for `#[rustc_const_unstable]` functions that are actually called from other, exposed-on-stable `const fn`. No other attributes are required.
2024-10-06 19:59:19 +02:00
#![feature(slice_as_chunks)]
#![feature(slice_ptr_get)]
#![feature(str_internals)]
#![feature(str_split_inclusive_remainder)]
#![feature(str_split_remainder)]
#![feature(ub_checks)]
#![feature(unchecked_neg)]
#![feature(unchecked_shifts)]
2022-03-07 16:36:13 -05:00
#![feature(utf16_extra)]
#![feature(variant_count)]
// tidy-alphabetical-end
2021-08-04 18:24:57 +02:00
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(strict_provenance))]
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
#![feature(abi_unadjusted)]
#![feature(adt_const_params)]
2021-08-05 11:58:52 -05:00
#![feature(allow_internal_unsafe)]
#![feature(allow_internal_unstable)]
#![feature(auto_traits)]
#![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)]
2022-02-23 08:06:22 -05:00
#![feature(cfg_target_has_atomic_equal_alignment)]
#![feature(cfg_ub_checks)]
#![feature(const_for)]
2024-10-23 14:22:56 -05:00
#![feature(const_is_char_boundary)]
#![feature(const_precise_live_drops)]
2024-10-23 14:22:56 -05:00
#![feature(const_str_split_at)]
#![feature(decl_macro)]
2022-04-05 22:42:23 +02:00
#![feature(deprecated_suggestion)]
#![feature(doc_cfg)]
#![feature(doc_cfg_hide)]
2021-05-06 13:36:07 +02:00
#![feature(doc_notable_trait)]
2018-04-02 11:26:16 +02:00
#![feature(extern_types)]
#![feature(f128)]
#![feature(f16)]
2024-03-19 09:34:31 -04:00
#![feature(freeze_impls)]
#![feature(fundamental)]
#![feature(generic_arg_infer)]
2021-08-16 17:29:49 +02:00
#![feature(if_let_guard)]
#![feature(intra_doc_pointers)]
#![feature(intrinsics)]
#![feature(lang_items)]
#![feature(let_chains)]
#![feature(link_llvm_intrinsics)]
#![feature(macro_metavar_expr)]
2024-06-14 12:16:15 +00:00
#![feature(marker_trait_attr)]
#![feature(min_specialization)]
#![feature(multiple_supertrait_upcastable)]
2021-10-19 09:27:59 +02:00
#![feature(must_not_suspend)]
2020-04-22 15:45:35 -04:00
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(no_core)]
#![feature(no_sanitize)]
#![feature(optimize_attribute)]
2017-03-17 15:05:44 +01:00
#![feature(prelude_import)]
#![feature(repr_simd)]
#![feature(rustc_allow_const_fn_unstable)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![feature(simd_ffi)]
#![feature(staged_api)]
#![feature(stmt_expr_attributes)]
#![feature(target_feature_11)]
#![feature(trait_alias)]
2019-07-04 10:05:50 -04:00
#![feature(transparent_unions)]
#![feature(try_blocks)]
#![feature(unboxed_closures)]
2020-11-19 15:01:48 -05:00
#![feature(unsized_fn_params)]
#![feature(with_negative_coherence)]
// tidy-alphabetical-end
2021-08-04 18:24:57 +02:00
//
// Target features:
// tidy-alphabetical-start
#![feature(arm_target_feature)]
#![feature(avx512_target_feature)]
#![feature(hexagon_target_feature)]
2024-03-22 11:02:29 -07:00
#![feature(loongarch_target_feature)]
#![feature(mips_target_feature)]
#![feature(powerpc_target_feature)]
#![feature(riscv_target_feature)]
#![feature(rtm_target_feature)]
#![feature(sha512_sm_x86)]
#![feature(sse4a_target_feature)]
#![feature(tbm_target_feature)]
#![feature(wasm_target_feature)]
#![feature(x86_amx_intrinsics)]
// tidy-alphabetical-end
// allow using `core::` in intra-doc links
#[allow(unused_extern_crates)]
extern crate self as core;
2016-08-22 10:02:28 +00:00
#[prelude_import]
#[allow(unused)]
use prelude::rust_2021::*;
#[cfg(not(test))] // See #65860
#[macro_use]
mod macros;
// We don't export this through #[macro_export] for now, to avoid breakage.
// See https://github.com/rust-lang/rust/issues/82913
#[cfg(not(test))]
#[unstable(feature = "assert_matches", issue = "82775")]
/// Unstable module containing the unstable `assert_matches` macro.
2021-07-16 09:18:14 -07:00
pub mod assert_matches {
#[unstable(feature = "assert_matches", issue = "82775")]
pub use crate::macros::{assert_matches, debug_assert_matches};
}
// We don't export this through #[macro_export] for now, to avoid breakage.
#[cfg(not(bootstrap))]
#[unstable(feature = "autodiff", issue = "124509")]
/// Unstable module containing the unstable `autodiff` macro.
pub mod autodiff {
#[unstable(feature = "autodiff", issue = "124509")]
pub use crate::macros::builtin::autodiff;
}
2023-10-25 09:42:56 -03:00
#[unstable(feature = "cfg_match", issue = "115585")]
pub use crate::macros::cfg_match;
2016-10-23 14:27:49 +01:00
#[macro_use]
mod internal_macros;
#[path = "num/shells/int_macros.rs"]
#[macro_use]
mod int_macros;
#[rustc_diagnostic_item = "i128_legacy_mod"]
#[path = "num/shells/i128.rs"]
2016-06-26 15:23:44 +02:00
pub mod i128;
#[rustc_diagnostic_item = "i16_legacy_mod"]
#[path = "num/shells/i16.rs"]
2016-06-26 15:23:44 +02:00
pub mod i16;
#[rustc_diagnostic_item = "i32_legacy_mod"]
#[path = "num/shells/i32.rs"]
2016-06-26 15:23:44 +02:00
pub mod i32;
#[rustc_diagnostic_item = "i64_legacy_mod"]
#[path = "num/shells/i64.rs"]
2016-06-26 15:23:44 +02:00
pub mod i64;
#[rustc_diagnostic_item = "i8_legacy_mod"]
#[path = "num/shells/i8.rs"]
2016-06-26 15:23:44 +02:00
pub mod i8;
#[rustc_diagnostic_item = "isize_legacy_mod"]
#[path = "num/shells/isize.rs"]
2018-05-27 11:53:43 +03:00
pub mod isize;
#[rustc_diagnostic_item = "u128_legacy_mod"]
#[path = "num/shells/u128.rs"]
pub mod u128;
#[rustc_diagnostic_item = "u16_legacy_mod"]
#[path = "num/shells/u16.rs"]
2016-06-26 15:23:44 +02:00
pub mod u16;
#[rustc_diagnostic_item = "u32_legacy_mod"]
#[path = "num/shells/u32.rs"]
2016-06-26 15:23:44 +02:00
pub mod u32;
#[rustc_diagnostic_item = "u64_legacy_mod"]
#[path = "num/shells/u64.rs"]
2016-06-26 15:23:44 +02:00
pub mod u64;
#[rustc_diagnostic_item = "u8_legacy_mod"]
#[path = "num/shells/u8.rs"]
2016-06-26 15:23:44 +02:00
pub mod u8;
#[rustc_diagnostic_item = "usize_legacy_mod"]
#[path = "num/shells/usize.rs"]
2018-05-27 11:53:43 +03:00
pub mod usize;
#[path = "num/f128.rs"]
pub mod f128;
#[path = "num/f16.rs"]
pub mod f16;
#[path = "num/f32.rs"]
pub mod f32;
#[path = "num/f64.rs"]
pub mod f64;
#[macro_use]
pub mod num;
/* The core prelude, not as all-encompassing as the std prelude */
pub mod prelude;
2014-04-30 20:04:56 -07:00
/* Core modules for ownership management */
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;
#[unstable(feature = "ub_checks", issue = "none")]
pub mod ub_checks;
2014-04-30 20:22:55 -07:00
/* Core language traits */
pub mod borrow;
pub mod clone;
pub mod cmp;
2014-04-30 20:55:38 -07:00
pub mod convert;
2014-04-30 20:46:51 -07:00
pub mod default;
2022-07-29 18:54:47 +00:00
pub mod error;
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;
pub mod array;
pub mod ascii;
2022-05-22 07:18:32 -03:00
pub mod asserting;
#[unstable(feature = "async_iterator", issue = "79024")]
pub mod async_iter;
2014-05-01 11:19:56 -07:00
pub mod cell;
pub mod char;
pub mod ffi;
#[unstable(feature = "core_io_borrowed_buf", issue = "117693")]
pub mod io;
2014-04-30 21:41:03 -07:00
pub mod iter;
2022-11-10 21:48:41 +01:00
pub mod net;
2014-04-30 21:35:56 -07:00
pub mod option;
pub mod panic;
pub mod panicking;
#[unstable(feature = "core_pattern_types", issue = "123646")]
2023-01-31 11:35:23 +00:00
pub mod pat;
pub mod pin;
#[unstable(feature = "random", issue = "130703")]
pub mod random;
#[unstable(feature = "new_range_api", issue = "125687")]
pub mod range;
pub mod result;
pub mod sync;
pub mod fmt;
pub mod hash;
pub mod slice;
pub mod str;
2017-12-11 13:42:01 -05:00
pub mod time;
pub mod unicode;
/* Async */
pub mod future;
pub mod task;
/* Heap memory allocator trait */
#[allow(missing_docs)]
pub mod alloc;
// note: does not need to be public
mod bool;
mod escape;
mod tuple;
mod unit;
2020-02-23 23:59:39 -08:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub mod primitive;
// Pull in the `core_arch` crate directly into core. 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 core, but the contents of this module are
2019-01-21 18:42:04 +01:00
// set up in such a way that directly pulling it here works such that the
// crate uses the this crate as its core.
2020-06-11 21:31:49 -05:00
#[path = "../../stdarch/crates/core_arch/src/mod.rs"]
#[allow(
missing_docs,
missing_debug_implementations,
dead_code,
unused_imports,
unsafe_op_in_unsafe_fn,
2023-10-03 22:27:25 -04:00
ambiguous_glob_reexports,
deprecated_in_future
)]
2021-05-06 13:36:07 +02:00
#[allow(rustdoc::bare_urls)]
2019-01-21 18:42:04 +01:00
mod core_arch;
#[stable(feature = "simd_arch", since = "1.27.0")]
2022-11-20 10:27:38 +01:00
pub mod arch;
// Pull in the `core_simd` crate directly into core. The contents of
// `core_simd` are in a different repository: rust-lang/portable-simd.
//
// `core_simd` depends on core, but the contents of this module are
// set up in such a way that directly pulling it here works such that the
// crate uses this crate as its core.
#[path = "../../portable-simd/crates/core_simd/src/mod.rs"]
#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn)]
#[allow(rustdoc::bare_urls)]
#[unstable(feature = "portable_simd", issue = "86656")]
mod core_simd;
#[unstable(feature = "portable_simd", issue = "86656")]
pub mod simd {
2023-11-19 13:08:53 -05:00
#![doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
#[unstable(feature = "portable_simd", issue = "86656")]
pub use crate::core_simd::simd::*;
}
include!("primitive_docs.rs");