      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306

    //! # The Rust Core Library
    //!
    //! The Rust Core Library is the dependency-free[^free] foundation of [The
    //! 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
    //! upstream libraries, no system libraries, and no libc.
    //!
    //! [^free]: Strictly speaking, there are some symbols which are needed but
    //!          they aren't always necessary.
    //!
    //! The core library is *minimal*: it isn't even aware of heap allocation,
    //! nor does it provide concurrency or I/O. These things require
    //! platform integration, and this library is platform-agnostic.
    //!
    //! # How to use the core library
    //!
    //! Please note that all of these details are currently not considered stable.
    //!
    // FIXME: Fill me in with more detail when the interface settles
    //! This library is built on the assumption of a few existing symbols:
    //!
    //! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
    //!   often generated by LLVM. Additionally, this library can make explicit
    //!   calls to these functions. Their signatures are the same as found in C.
    //!   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).
    //!
    //! * `rust_begin_panic` - This function takes four arguments, a
    //!   `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments
    //!   dictate the panic message, the file at which panic was invoked, and the
    //!   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
    //!   return. This requires a `lang` attribute named `panic_impl`.
    //!
    //! * `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 libcore defines many fundamental lang items, all tests live in a
    // separate crate, libcoretest, to avoid bizarre issues.
    //
    // 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,
    // and this will cause the E0152 "found duplicate lang item" error. See
    // discussion in #50466 for details.
    //
    // This cfg won't affect doc tests.
    #![cfg(not(test))]
    #![stable(feature = "core", since = "1.6.0")]
    #![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)))
    )]
    #![no_core]
    #![warn(deprecated_in_future)]
    #![warn(missing_docs)]
    #![warn(missing_debug_implementations)]
    #![allow(explicit_outlives_requirements)]
    #![allow(incomplete_features)]
    #![feature(allow_internal_unstable)]
    #![feature(arbitrary_self_types)]
    #![feature(asm)]
    #![feature(bound_cloned)]
    #![feature(cfg_target_has_atomic)]
    #![feature(concat_idents)]
    #![feature(const_alloc_layout)]
    #![feature(const_discriminant)]
    #![feature(const_checked_int_methods)]
    #![feature(const_euclidean_int_methods)]
    #![feature(const_float_classify)]
    #![feature(const_float_bits_conv)]
    #![feature(const_overflowing_int_methods)]
    #![feature(const_int_unchecked_arith)]
    #![feature(const_int_pow)]
    #![feature(constctlz)]
    #![feature(const_panic)]
    #![feature(const_fn_union)]
    #![feature(const_generics)]
    #![feature(const_option)]
    #![feature(const_precise_live_drops)]
    #![feature(const_ptr_offset)]
    #![feature(const_ptr_offset_from)]
    #![feature(const_raw_ptr_comparison)]
    #![feature(const_result)]
    #![feature(const_slice_from_raw_parts)]
    #![feature(const_slice_ptr_len)]
    #![feature(const_size_of_val)]
    #![feature(const_align_of_val)]
    #![feature(const_type_id)]
    #![feature(const_type_name)]
    #![feature(const_likely)]
    #![feature(const_unreachable_unchecked)]
    #![feature(custom_inner_attributes)]
    #![feature(decl_macro)]
    #![feature(doc_cfg)]
    #![cfg_attr(not(bootstrap), feature(doc_spotlight))]
    #![feature(duration_consts_2)]
    #![feature(extern_types)]
    #![feature(fundamental)]
    #![feature(intrinsics)]
    #![feature(try_find)]
    #![feature(is_sorted)]
    #![feature(lang_items)]
    #![feature(link_llvm_intrinsics)]
    #![feature(llvm_asm)]
    #![feature(negative_impls)]
    #![feature(never_type)]
    #![feature(nll)]
    #![feature(exhaustive_patterns)]
    #![feature(no_core)]
    #![feature(optin_builtin_traits)]
    #![feature(or_patterns)]
    #![feature(prelude_import)]
    #![feature(ptr_as_uninit)]
    #![feature(repr_simd, platform_intrinsics)]
    #![feature(rustc_attrs)]
    #![feature(simd_ffi)]
    #![feature(min_specialization)]
    #![feature(staged_api)]
    #![feature(std_internals)]
    #![feature(stmt_expr_attributes)]
    #![feature(transparent_unions)]
    #![feature(unboxed_closures)]
    #![feature(unsized_locals)]
    #![feature(untagged_unions)]
    #![feature(unwind_attributes)]
    #![feature(variant_count)]
    #![feature(doc_alias)]
    #![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)]
    #![feature(wasm_target_feature)]
    #![feature(avx512_target_feature)]
    #![feature(cmpxchg16b_target_feature)]
    #![feature(rtm_target_feature)]
    #![feature(f16c_target_feature)]
    #![feature(hexagon_target_feature)]
    #![feature(const_fn_transmute)]
    #![feature(abi_unadjusted)]
    #![feature(adx_target_feature)]
    #![feature(maybe_uninit_slice)]
    #![feature(maybe_uninit_extra)]
    #![feature(external_doc)]
    #![feature(associated_type_bounds)]
    #![feature(const_caller_location)]
    #![feature(slice_ptr_get)]
    #![feature(no_niche)] // rust-lang/rust#68303
    #![feature(unsafe_block_in_unsafe_fn)]
    #![deny(unsafe_op_in_unsafe_fn)]

    #[prelude_import]
    #[allow(unused)]
    use prelude::v1::*;

    #[cfg(not(test))] // See #65860
    #[macro_use]
    mod macros;

    #[macro_use]
    mod internal_macros;

    #[path = "num/int_macros.rs"]
    #[macro_use]
    mod int_macros;

    #[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;

    #[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;

    #[path = "num/f32.rs"]
    pub mod f32;
    #[path = "num/f64.rs"]
    pub mod f64;

    #[macro_use]
    pub mod num;

    /* The libcore prelude, not as all-encompassing as the libstd prelude */

    pub mod prelude;

    /* Core modules for ownership management */

    pub mod hint;
    pub mod intrinsics;
    pub mod mem;
    pub mod ptr;

    /* Core language traits */

    pub mod borrow;
    #[cfg(not(test))] // See #65860
    pub mod clone;
    #[cfg(not(test))] // See #65860
    pub mod cmp;
    pub mod convert;
    #[cfg(not(test))] // See #65860
    pub mod default;
    #[cfg(not(test))] // See #65860
    pub mod marker;
    pub mod ops;

    /* Core types and methods on primitives */

    pub mod any;
    #[cfg(not(test))] // See #65860
    pub mod array;
    pub mod ascii;
    pub mod cell;
    pub mod char;
    pub mod ffi;
    #[cfg(not(test))] // See #65860
    pub mod iter;
    #[unstable(feature = "once_cell", issue = "74465")]
    pub mod lazy;
    pub mod option;
    pub mod panic;
    pub mod panicking;
    #[cfg(not(test))] // See #65860
    pub mod pin;
    pub mod raw;
    pub mod result;
    pub mod sync;

    #[cfg(not(test))] // See #65860
    pub mod fmt;
    #[cfg(not(test))] // See #65860
    pub mod hash;
    pub mod slice;
    #[cfg(not(test))] // See #65860
    pub mod str;
    pub mod time;

    pub mod unicode;

    /* Async */
    #[cfg(not(test))] // See #65860
    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 tuple;
    mod unit;

    #[stable(feature = "core_primitive", since = "1.43.0")]
    pub mod primitive;

    // Pull in the `core_arch` crate directly into libcore. The contents of
    // `core_arch` are in a different repository: rust-lang/stdarch.
    //
    // `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.
    #[path = "../../stdarch/crates/core_arch/src/mod.rs"]
    #[allow(
        missing_docs,
        missing_debug_implementations,
        dead_code,
        unused_imports,
        unsafe_op_in_unsafe_fn
    )]
    // FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
    // merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
    #[allow(clashing_extern_declarations)]
    #[unstable(feature = "stdsimd", issue = "48556")]
    mod core_arch;

    #[stable(feature = "simd_arch", since = "1.27.0")]
    pub use core_arch::arch;