]> git.proxmox.com Git - rustc.git/blame - src/libstd/lib.rs
New upstream version 1.43.0+dfsg1
[rustc.git] / src / libstd / lib.rs
CommitLineData
1a4d82fc
JJ
1//! # The Rust Standard Library
2//!
92a42be0
SL
3//! The Rust Standard Library is the foundation of portable Rust software, a
4//! set of minimal and battle-tested shared abstractions for the [broader Rust
5//! ecosystem][crates.io]. It offers core types, like [`Vec<T>`] and
6//! [`Option<T>`], library-defined [operations on language
7//! primitives](#primitives), [standard macros](#macros), [I/O] and
8//! [multithreading], among [many other things][other].
9//!
9fa01778 10//! `std` is available to all Rust crates by default. Therefore, the
92a42be0 11//! standard library can be accessed in [`use`] statements through the path
9fa01778 12//! `std`, as in [`use std::env`].
1a4d82fc 13//!
c1a9b12d 14//! # How to read this documentation
1a4d82fc 15//!
9cc50fc6 16//! If you already know the name of what you are looking for, the fastest way to
92a42be0
SL
17//! find it is to use the <a href="#" onclick="focusSearchBar();">search
18//! bar</a> at the top of the page.
1a4d82fc 19//!
c1a9b12d
SL
20//! Otherwise, you may want to jump to one of these useful sections:
21//!
22//! * [`std::*` modules](#modules)
23//! * [Primitive types](#primitives)
24//! * [Standard macros](#macros)
25//! * [The Rust Prelude](prelude/index.html)
26//!
92a42be0
SL
27//! If this is your first time, the documentation for the standard library is
28//! written to be casually perused. Clicking on interesting things should
29//! generally lead you to interesting places. Still, there are important bits
30//! you don't want to miss, so read on for a tour of the standard library and
31//! its documentation!
c1a9b12d 32//!
92a42be0
SL
33//! Once you are familiar with the contents of the standard library you may
34//! begin to find the verbosity of the prose distracting. At this stage in your
83c7162d 35//! development you may want to press the `[-]` button near the top of the
92a42be0 36//! page to collapse it into a more skimmable view.
c1a9b12d 37//!
83c7162d 38//! While you are looking at that `[-]` button also notice the `[src]`
92a42be0
SL
39//! button. Rust's API documentation comes with the source code and you are
40//! encouraged to read it. The standard library source is generally high
41//! quality and a peek behind the curtains is often enlightening.
c1a9b12d
SL
42//!
43//! # What is in the standard library documentation?
44//!
92a42be0
SL
45//! First of all, The Rust Standard Library is divided into a number of focused
46//! modules, [all listed further down this page](#modules). These modules are
47//! the bedrock upon which all of Rust is forged, and they have mighty names
48//! like [`std::slice`] and [`std::cmp`]. Modules' documentation typically
49//! includes an overview of the module along with examples, and are a smart
50//! place to start familiarizing yourself with the library.
c1a9b12d 51//!
92a42be0 52//! Second, implicit methods on [primitive types] are documented here. This can
c1a9b12d
SL
53//! be a source of confusion for two reasons:
54//!
92a42be0
SL
55//! 1. While primitives are implemented by the compiler, the standard library
56//! implements methods directly on the primitive types (and it is the only
57//! library that does so), which are [documented in the section on
58//! primitives](#primitives).
59//! 2. The standard library exports many modules *with the same name as
60//! primitive types*. These define additional items related to the primitive
61//! type, but not the all-important methods.
c1a9b12d
SL
62//!
63//! So for example there is a [page for the primitive type
92a42be0
SL
64//! `i32`](primitive.i32.html) that lists all the methods that can be called on
65//! 32-bit integers (very useful), and there is a [page for the module
66//! `std::i32`](i32/index.html) that documents the constant values [`MIN`] and
67//! [`MAX`](i32/constant.MAX.html) (rarely useful).
68//!
69//! Note the documentation for the primitives [`str`] and [`[T]`][slice] (also
70//! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
71//! calls to methods on [`str`] and [`[T]`][slice] respectively, via [deref
3b2f2976 72//! coercions][deref-coercions].
92a42be0
SL
73//!
74//! Third, the standard library defines [The Rust Prelude], a small collection
75//! of items - mostly traits - that are imported into every module of every
76//! crate. The traits in the prelude are pervasive, making the prelude
c1a9b12d
SL
77//! documentation a good entry point to learning about the library.
78//!
92a42be0
SL
79//! And finally, the standard library exports a number of standard macros, and
80//! [lists them on this page](#macros) (technically, not all of the standard
81//! macros are defined by the standard library - some are defined by the
82//! compiler - but they are documented here the same). Like the prelude, the
83//! standard macros are imported by default into all crates.
c1a9b12d 84//!
cc61c64b
XL
85//! # Contributing changes to the documentation
86//!
87//! Check out the rust contribution guidelines [here](
88//! https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md).
89//! The source for this documentation can be found on [Github](https://github.com/rust-lang).
90//! To contribute changes, make sure you read the guidelines first, then submit
91//! pull-requests for your suggested changes.
92//!
93//! Contributions are appreciated! If you see a part of the docs that can be
94//! improved, submit a PR, or chat with us first on irc.mozilla.org #rust-docs.
95//!
c1a9b12d
SL
96//! # A Tour of The Rust Standard Library
97//!
92a42be0
SL
98//! The rest of this crate documentation is dedicated to pointing out notable
99//! features of The Rust Standard Library.
1a4d82fc 100//!
bd371182 101//! ## Containers and collections
1a4d82fc 102//!
92a42be0
SL
103//! The [`option`] and [`result`] modules define optional and error-handling
104//! types, [`Option<T>`] and [`Result<T, E>`]. The [`iter`] module defines
105//! Rust's iterator trait, [`Iterator`], which works with the [`for`] loop to
106//! access collections.
1a4d82fc 107//!
92a42be0 108//! The standard library exposes three common ways to deal with contiguous
c1a9b12d
SL
109//! regions of memory:
110//!
92a42be0
SL
111//! * [`Vec<T>`] - A heap-allocated *vector* that is resizable at runtime.
112//! * [`[T; n]`][array] - An inline *array* with a fixed size at compile time.
113//! * [`[T]`][slice] - A dynamically sized *slice* into any other kind of contiguous
114//! storage, whether heap-allocated or not.
c1a9b12d 115//!
92a42be0
SL
116//! Slices can only be handled through some kind of *pointer*, and as such come
117//! in many flavors such as:
1a4d82fc 118//!
c1a9b12d
SL
119//! * `&[T]` - *shared slice*
120//! * `&mut [T]` - *mutable slice*
92a42be0 121//! * [`Box<[T]>`][owned slice] - *owned slice*
c1a9b12d 122//!
92a42be0
SL
123//! [`str`], a UTF-8 string slice, is a primitive type, and the standard library
124//! defines many methods for it. Rust [`str`]s are typically accessed as
125//! immutable references: `&str`. Use the owned [`String`] for building and
126//! mutating strings.
1a4d82fc 127//!
92a42be0
SL
128//! For converting to strings use the [`format!`] macro, and for converting from
129//! strings use the [`FromStr`] trait.
1a4d82fc 130//!
92a42be0
SL
131//! Data may be shared by placing it in a reference-counted box or the [`Rc`]
132//! type, and if further contained in a [`Cell`] or [`RefCell`], may be mutated
133//! as well as shared. Likewise, in a concurrent setting it is common to pair an
134//! atomically-reference-counted box, [`Arc`], with a [`Mutex`] to get the same
135//! effect.
bd371182 136//!
92a42be0
SL
137//! The [`collections`] module defines maps, sets, linked lists and other
138//! typical collection types, including the common [`HashMap<K, V>`].
bd371182
AL
139//!
140//! ## Platform abstractions and I/O
1a4d82fc 141//!
92a42be0
SL
142//! Besides basic data types, the standard library is largely concerned with
143//! abstracting over differences in common platforms, most notably Windows and
144//! Unix derivatives.
145//!
146//! Common types of I/O, including [files], [TCP], [UDP], are defined in the
147//! [`io`], [`fs`], and [`net`] modules.
148//!
149//! The [`thread`] module contains Rust's threading abstractions. [`sync`]
150//! contains further primitive shared memory types, including [`atomic`] and
151//! [`mpsc`], which contains the channel types for message passing.
152//!
153//! [I/O]: io/index.html
9cc50fc6 154//! [`MIN`]: i32/constant.MIN.html
92a42be0
SL
155//! [TCP]: net/struct.TcpStream.html
156//! [The Rust Prelude]: prelude/index.html
157//! [UDP]: net/struct.UdpSocket.html
92a42be0
SL
158//! [`Arc`]: sync/struct.Arc.html
159//! [owned slice]: boxed/index.html
160//! [`Cell`]: cell/struct.Cell.html
161//! [`FromStr`]: str/trait.FromStr.html
162//! [`HashMap<K, V>`]: collections/struct.HashMap.html
163//! [`Iterator`]: iter/trait.Iterator.html
164//! [`Mutex`]: sync/struct.Mutex.html
165//! [`Option<T>`]: option/enum.Option.html
74b04a01 166//! [`Rc`]: rc/struct.Rc.html
92a42be0
SL
167//! [`RefCell`]: cell/struct.RefCell.html
168//! [`Result<T, E>`]: result/enum.Result.html
169//! [`String`]: string/struct.String.html
74b04a01 170//! [`Vec<T>`]: vec/struct.Vec.html
92a42be0
SL
171//! [array]: primitive.array.html
172//! [slice]: primitive.slice.html
173//! [`atomic`]: sync/atomic/index.html
174//! [`collections`]: collections/index.html
13cf67c4 175//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
9e0c209e 176//! [`format!`]: macro.format.html
92a42be0
SL
177//! [`fs`]: fs/index.html
178//! [`io`]: io/index.html
179//! [`iter`]: iter/index.html
180//! [`mpsc`]: sync/mpsc/index.html
181//! [`net`]: net/index.html
182//! [`option`]: option/index.html
183//! [`result`]: result/index.html
184//! [`std::cmp`]: cmp/index.html
185//! [`std::slice`]: slice/index.html
186//! [`str`]: primitive.str.html
187//! [`sync`]: sync/index.html
188//! [`thread`]: thread/index.html
189//! [`use std::env`]: env/index.html
532ac7d7 190//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
92a42be0 191//! [crates.io]: https://crates.io
13cf67c4 192//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
92a42be0
SL
193//! [files]: fs/struct.File.html
194//! [multithreading]: thread/index.html
195//! [other]: #what-is-in-the-standard-library-documentation
13cf67c4 196//! [primitive types]: ../book/ch03-02-data-types.html
bd371182 197
85aaf69f 198#![stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
199#![doc(
200 html_root_url = "https://doc.rust-lang.org/nightly/",
201 html_playground_url = "https://play.rust-lang.org/",
202 issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
203 test(no_crate_inject, attr(deny(warnings))),
204 test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
205)]
c30ab7b3
SL
206// Don't link to std. We are std.
207#![no_std]
416331ca 208#![warn(deprecated_in_future)]
48663c56
XL
209#![warn(missing_docs)]
210#![warn(missing_debug_implementations)]
211#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
532ac7d7 212#![allow(explicit_outlives_requirements)]
416331ca 213#![allow(unused_lifetimes)]
c30ab7b3 214// Tell the compiler to link to either panic_abort or panic_unwind
3157f602 215#![needs_panic_runtime]
c30ab7b3
SL
216// std may use features in a platform-specific way
217#![allow(unused_features)]
416331ca 218#![cfg_attr(test, feature(print_internals, set_stdio, update_panic_count))]
dfeec247
XL
219#![cfg_attr(
220 all(target_vendor = "fortanix", target_env = "sgx"),
221 feature(slice_index_methods, coerce_unsized, sgx_platform, ptr_wrapping_offset_from)
222)]
223#![cfg_attr(
224 all(test, target_vendor = "fortanix", target_env = "sgx"),
225 feature(fixed_size_array, maybe_uninit_extra)
226)]
c30ab7b3
SL
227// std is implemented with unstable features, many of which are internal
228// compiler details that will never be stable
9fa01778 229// NB: the following list is sorted to minimize merge conflicts.
8faf50e0 230#![feature(alloc_error_handler)]
9fa01778 231#![feature(alloc_layout_extra)]
8faf50e0 232#![feature(allocator_api)]
041b39d2 233#![feature(allocator_internals)]
3b2f2976 234#![feature(allow_internal_unsafe)]
d9579d0f 235#![feature(allow_internal_unstable)]
94b46f34 236#![feature(arbitrary_self_types)]
abe05a73 237#![feature(array_error_internals)]
92a42be0 238#![feature(asm)]
416331ca 239#![feature(associated_type_bounds)]
74b04a01 240#![feature(atomic_mut_ptr)]
1a4d82fc 241#![feature(box_syntax)]
a1dfa0c6 242#![feature(c_variadic)]
c30ab7b3 243#![feature(cfg_target_has_atomic)]
9cc50fc6 244#![feature(cfg_target_thread_local)]
041b39d2 245#![feature(char_error_internals)]
532ac7d7 246#![feature(clamp)]
0731742a 247#![feature(concat_idents)]
0bf4aa26 248#![feature(const_cstr_unchecked)]
9fa01778 249#![feature(const_raw_ptr_deref)]
e1599b0c 250#![feature(container_error_extra)]
62682a34 251#![feature(core_intrinsics)]
416331ca 252#![feature(custom_test_frameworks)]
e74abb32 253#![feature(decl_macro)]
9fa01778
XL
254#![feature(doc_alias)]
255#![feature(doc_cfg)]
256#![feature(doc_keyword)]
257#![feature(doc_masked)]
32a655c1 258#![feature(dropck_eyepatch)]
0731742a 259#![feature(duration_constants)]
476ff2be 260#![feature(exact_size_is_empty)]
9fa01778 261#![feature(exhaustive_patterns)]
2c00a5a8 262#![feature(external_doc)]
54a0048b 263#![feature(fn_traits)]
416331ca 264#![feature(format_args_nl)]
8faf50e0 265#![feature(generator_trait)]
416331ca 266#![feature(global_asm)]
9fa01778 267#![feature(hash_raw_entry)]
0531ce1d 268#![feature(hashmap_internals)]
62682a34 269#![feature(int_error_internals)]
48663c56 270#![feature(int_error_matching)]
c30ab7b3 271#![feature(integer_atomics)]
85aaf69f
SL
272#![feature(lang_items)]
273#![feature(libc)]
92a42be0
SL
274#![feature(link_args)]
275#![feature(linkage)]
416331ca
XL
276#![feature(log_syntax)]
277#![feature(maybe_uninit_ref)]
278#![feature(maybe_uninit_slice)]
5bcae85e 279#![feature(needs_panic_runtime)]
cc61c64b 280#![feature(never_type)]
0bf4aa26 281#![feature(nll)]
85aaf69f 282#![feature(optin_builtin_traits)]
9fa01778 283#![feature(panic_info_message)]
0531ce1d 284#![feature(panic_internals)]
a7813a04 285#![feature(panic_unwind)]
9e0c209e 286#![feature(prelude_import)]
2c00a5a8 287#![feature(ptr_internals)]
62682a34 288#![feature(raw)]
9fa01778 289#![feature(renamed_spin_loop)]
54a0048b 290#![feature(rustc_attrs)]
9fa01778 291#![feature(rustc_private)]
0531ce1d 292#![feature(shrink_to)]
92a42be0 293#![feature(slice_concat_ext)]
ff7c6d11 294#![feature(slice_internals)]
e74abb32 295#![feature(specialization)]
85aaf69f 296#![feature(staged_api)]
9fa01778
XL
297#![feature(std_internals)]
298#![feature(stdsimd)]
9cc50fc6 299#![feature(stmt_expr_attributes)]
62682a34 300#![feature(str_internals)]
416331ca 301#![feature(test)]
92a42be0 302#![feature(thread_local)]
cc61c64b 303#![feature(toowned_clone_into)]
416331ca 304#![feature(trace_macros)]
dfeec247 305#![feature(track_caller)]
0531ce1d 306#![feature(try_reserve)]
85aaf69f 307#![feature(unboxed_closures)]
8bb4bdeb 308#![feature(untagged_unions)]
e9174d1e 309#![feature(unwind_attributes)]
74b04a01 310#![feature(vec_into_raw_parts)]
9fa01778 311// NB: the above list is sorted to minimize merge conflicts.
3b2f2976
XL
312#![default_lib_allocator]
313
c30ab7b3
SL
314// Explicitly import the prelude. The compiler uses this same unstable attribute
315// to import the prelude implicitly when building crates that depend on std.
9e0c209e
SL
316#[prelude_import]
317#[allow(unused)]
318use prelude::v1::*;
319
c30ab7b3 320// Access to Bencher, etc.
dfeec247
XL
321#[cfg(test)]
322extern crate test;
1a4d82fc 323
83c7162d 324#[allow(unused_imports)] // macros from `alloc` are not used on all platforms
1a4d82fc 325#[macro_use]
83c7162d 326extern crate alloc as alloc_crate;
ea8adc8c 327#[doc(masked)]
532ac7d7 328#[allow(unused_extern_crates)]
1a4d82fc
JJ
329extern crate libc;
330
a7813a04 331// We always need an unwinder currently for backtraces
ea8adc8c 332#[doc(masked)]
3b2f2976 333#[allow(unused_extern_crates)]
a7813a04
XL
334extern crate unwind;
335
c30ab7b3
SL
336// During testing, this crate is not actually the "real" std library, but rather
337// it links to the real std library, which was compiled from this same source
338// code. So any lang items std defines are conditionally excluded (or else they
83c7162d 339// would generate duplicate lang item errors), and any globals it defines are
c30ab7b3
SL
340// _not_ the globals used by "real" std. So this import, defined only during
341// testing gives test-std access to real-std lang items and globals. See #2912
dfeec247
XL
342#[cfg(test)]
343extern crate std as realstd;
1a4d82fc 344
c30ab7b3
SL
345// The standard macros that are not built-in to the compiler.
346#[macro_use]
347mod macros;
348
349// The Rust prelude
350pub mod prelude;
1a4d82fc 351
2c00a5a8 352// Public module declarations and re-exports
92a42be0 353#[stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
354pub use alloc_crate::borrow;
355#[stable(feature = "rust1", since = "1.0.0")]
356pub use alloc_crate::boxed;
357#[stable(feature = "rust1", since = "1.0.0")]
358pub use alloc_crate::fmt;
359#[stable(feature = "rust1", since = "1.0.0")]
360pub use alloc_crate::format;
361#[stable(feature = "rust1", since = "1.0.0")]
362pub use alloc_crate::rc;
363#[stable(feature = "rust1", since = "1.0.0")]
364pub use alloc_crate::slice;
365#[stable(feature = "rust1", since = "1.0.0")]
366pub use alloc_crate::str;
367#[stable(feature = "rust1", since = "1.0.0")]
368pub use alloc_crate::string;
369#[stable(feature = "rust1", since = "1.0.0")]
370pub use alloc_crate::vec;
371#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 372pub use core::any;
9fa01778
XL
373#[stable(feature = "simd_arch", since = "1.27.0")]
374#[doc(no_inline)]
375pub use core::arch;
dfeec247
XL
376#[stable(feature = "core_array", since = "1.36.0")]
377pub use core::array;
92a42be0 378#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 379pub use core::cell;
92a42be0 380#[stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
381pub use core::char;
382#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 383pub use core::clone;
92a42be0 384#[stable(feature = "rust1", since = "1.0.0")]
c1a9b12d 385pub use core::cmp;
92a42be0 386#[stable(feature = "rust1", since = "1.0.0")]
c34b1796 387pub use core::convert;
92a42be0 388#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 389pub use core::default;
92a42be0 390#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 391pub use core::hash;
dfeec247
XL
392#[stable(feature = "core_hint", since = "1.27.0")]
393pub use core::hint;
394#[stable(feature = "i128", since = "1.26.0")]
395pub use core::i128;
396#[stable(feature = "rust1", since = "1.0.0")]
397pub use core::i16;
398#[stable(feature = "rust1", since = "1.0.0")]
399pub use core::i32;
400#[stable(feature = "rust1", since = "1.0.0")]
401pub use core::i64;
402#[stable(feature = "rust1", since = "1.0.0")]
403pub use core::i8;
92a42be0 404#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 405pub use core::intrinsics;
92a42be0 406#[stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
407pub use core::isize;
408#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 409pub use core::iter;
92a42be0 410#[stable(feature = "rust1", since = "1.0.0")]
c1a9b12d 411pub use core::marker;
92a42be0 412#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 413pub use core::mem;
92a42be0 414#[stable(feature = "rust1", since = "1.0.0")]
c1a9b12d 415pub use core::ops;
92a42be0 416#[stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
417pub use core::option;
418#[stable(feature = "pin", since = "1.33.0")]
419pub use core::pin;
420#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 421pub use core::ptr;
92a42be0 422#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 423pub use core::raw;
92a42be0 424#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 425pub use core::result;
0531ce1d 426#[stable(feature = "i128", since = "1.26.0")]
dfeec247 427pub use core::u128;
92a42be0 428#[stable(feature = "rust1", since = "1.0.0")]
e9174d1e 429pub use core::u16;
92a42be0 430#[stable(feature = "rust1", since = "1.0.0")]
e9174d1e 431pub use core::u32;
92a42be0 432#[stable(feature = "rust1", since = "1.0.0")]
e9174d1e 433pub use core::u64;
c30ab7b3 434#[stable(feature = "rust1", since = "1.0.0")]
dfeec247 435pub use core::u8;
c30ab7b3 436#[stable(feature = "rust1", since = "1.0.0")]
dfeec247 437pub use core::usize;
1a4d82fc 438
c30ab7b3
SL
439pub mod f32;
440pub mod f64;
1a4d82fc
JJ
441
442#[macro_use]
c34b1796 443pub mod thread;
c30ab7b3 444pub mod ascii;
e1599b0c 445pub mod backtrace;
c34b1796 446pub mod collections;
c34b1796 447pub mod env;
c30ab7b3 448pub mod error;
1a4d82fc 449pub mod ffi;
85aaf69f 450pub mod fs;
c34b1796 451pub mod io;
85aaf69f 452pub mod net;
c30ab7b3 453pub mod num;
1a4d82fc 454pub mod os;
9cc50fc6 455pub mod panic;
1a4d82fc 456pub mod path;
85aaf69f 457pub mod process;
c34b1796 458pub mod sync;
1a4d82fc 459pub mod time;
83c7162d 460
48663c56 461#[stable(feature = "futures_api", since = "1.36.0")]
8faf50e0
XL
462pub mod task {
463 //! Types and Traits for working with asynchronous tasks.
464 #[doc(inline)]
48663c56 465 #[stable(feature = "futures_api", since = "1.36.0")]
8faf50e0 466 pub use core::task::*;
8faf50e0
XL
467}
468
48663c56 469#[stable(feature = "futures_api", since = "1.36.0")]
8faf50e0
XL
470pub mod future;
471
c30ab7b3 472// Platform-abstraction modules
c34b1796 473#[macro_use]
c30ab7b3
SL
474mod sys_common;
475mod sys;
1a4d82fc 476
83c7162d
XL
477pub mod alloc;
478
c30ab7b3 479// Private support modules
c30ab7b3 480mod memchr;
dfeec247 481mod panicking;
c30ab7b3 482
c30ab7b3
SL
483// The runtime entry point and a few unstable public functions used by the
484// compiler
485pub mod rt;
ff7c6d11 486
9fa01778 487// Pull in the `std_detect` crate directly into libstd. The contents of
416331ca 488// `std_detect` are in a different repository: rust-lang/stdarch.
0531ce1d 489//
9fa01778
XL
490// `std_detect` depends on libstd, but the contents of this module are
491// set up in such a way that directly pulling it here works such that the
492// crate uses the this crate as its libstd.
416331ca 493#[path = "../stdarch/crates/std_detect/src/mod.rs"]
0531ce1d
XL
494#[allow(missing_debug_implementations, missing_docs, dead_code)]
495#[unstable(feature = "stdsimd", issue = "48556")]
0731742a 496#[cfg(not(test))]
9fa01778 497mod std_detect;
0531ce1d 498
9fa01778
XL
499#[doc(hidden)]
500#[unstable(feature = "stdsimd", issue = "48556")]
0731742a 501#[cfg(not(test))]
9fa01778 502pub use std_detect::detect;
9346a6ac 503
416331ca
XL
504// Re-export macros defined in libcore.
505#[stable(feature = "rust1", since = "1.0.0")]
e1599b0c 506#[allow(deprecated, deprecated_in_future)]
416331ca
XL
507pub use core::{
508 // Stable
509 assert_eq,
510 assert_ne,
dfeec247 511 debug_assert,
416331ca
XL
512 debug_assert_eq,
513 debug_assert_ne,
dfeec247
XL
514 // Unstable
515 matches,
416331ca 516 r#try,
dfeec247 517 todo,
416331ca
XL
518 unimplemented,
519 unreachable,
520 write,
521 writeln,
416331ca
XL
522};
523
524// Re-export built-in macros defined through libcore.
416331ca
XL
525#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
526pub use core::{
dfeec247
XL
527 // Unstable
528 asm,
416331ca
XL
529 // Stable
530 assert,
531 cfg,
532 column,
533 compile_error,
534 concat,
dfeec247 535 concat_idents,
416331ca
XL
536 env,
537 file,
538 format_args,
dfeec247
XL
539 format_args_nl,
540 global_asm,
416331ca
XL
541 include,
542 include_bytes,
543 include_str,
544 line,
dfeec247 545 log_syntax,
416331ca
XL
546 module_path,
547 option_env,
548 stringify,
416331ca
XL
549 trace_macros,
550};
551
74b04a01
XL
552#[stable(feature = "core_primitive", since = "1.43.0")]
553pub use core::primitive;
554
c1a9b12d
SL
555// Include a number of private modules that exist solely to provide
556// the rustdoc documentation for primitive types. Using `include!`
557// because rustdoc only looks for these modules at the crate level.
558include!("primitive_docs.rs");
94b46f34
XL
559
560// Include a number of private modules that exist solely to provide
561// the rustdoc documentation for the existing keywords. Using `include!`
562// because rustdoc only looks for these modules at the crate level.
563include!("keyword_docs.rs");