Skip to main content

std/
lib.rs

1//! **You are viewing the documentation of the Rust standard library as a part
2//! of the Fortanix Rust EDP.** The only changes compared to the normal Rust
3//! standard library are the addition of the [`std::os::fortanix_sgx` module].
4//!
5//! [`std::os::fortanix_sgx` module]: os/fortanix_sgx/
6//!
7//! ---
8//!
9//! # The Rust Standard Library
10//!
11//! The Rust Standard Library is the foundation of portable Rust software, a
12//! set of minimal and battle-tested shared abstractions for the [broader Rust
13//! ecosystem][crates.io]. It offers core types, like [`Vec<T>`] and
14//! [`Option<T>`], library-defined [operations on language
15//! primitives](#primitives), [standard macros](#macros), [I/O] and
16//! [multithreading], among [many other things][other].
17//!
18//! `std` is available to all Rust crates by default. Therefore, the
19//! standard library can be accessed in [`use`] statements through the path
20//! `std`, as in [`use std::env`].
21//!
22//! # How to read this documentation
23//!
24//! If you already know the name of what you are looking for, the fastest way to
25//! find it is to use the <a href="#" onclick="window.searchState.focus();">search
26//! button</a> at the top of the page.
27//!
28//! Otherwise, you may want to jump to one of these useful sections:
29//!
30//! * [`std::*` modules](#modules)
31//! * [Primitive types](#primitives)
32//! * [Standard macros](#macros)
33//! * [The Rust Prelude]
34//!
35//! If this is your first time, the documentation for the standard library is
36//! written to be casually perused. Clicking on interesting things should
37//! generally lead you to interesting places. Still, there are important bits
38//! you don't want to miss, so read on for a tour of the standard library and
39//! its documentation!
40//!
41//! Once you are familiar with the contents of the standard library you may
42//! begin to find the verbosity of the prose distracting. At this stage in your
43//! development you may want to press the
44//! "<svg style="width:0.75rem;height:0.75rem" viewBox="0 0 12 12" stroke="currentColor" fill="none"><path d="M2,2l4,4l4,-4M2,6l4,4l4,-4"/></svg>&nbsp;Summary"
45//! button near the top of the page to collapse it into a more skimmable view.
46//!
47//! While you are looking at the top of the page, also notice the
48//! "Source" link. Rust's API documentation comes with the source
49//! code and you are encouraged to read it. The standard library source is
50//! generally high quality and a peek behind the curtains is
51//! often enlightening.
52//!
53//! # What is in the standard library documentation?
54//!
55//! First of all, The Rust Standard Library is divided into a number of focused
56//! modules, [all listed further down this page](#modules). These modules are
57//! the bedrock upon which all of Rust is forged, and they have mighty names
58//! like [`std::slice`] and [`std::cmp`]. Modules' documentation typically
59//! includes an overview of the module along with examples, and are a smart
60//! place to start familiarizing yourself with the library.
61//!
62//! Second, implicit methods on [primitive types] are documented here. This can
63//! be a source of confusion for two reasons:
64//!
65//! 1. While primitives are implemented by the compiler, the standard library
66//!    implements methods directly on the primitive types (and it is the only
67//!    library that does so), which are [documented in the section on
68//!    primitives](#primitives).
69//! 2. The standard library exports many modules *with the same name as
70//!    primitive types*. These define additional items related to the primitive
71//!    type, but not the all-important methods.
72//!
73//! So for example there is a [page for the primitive type
74//! `char`](primitive::char) that lists all the methods that can be called on
75//! characters (very useful), and there is a [page for the module
76//! `std::char`](crate::char) that documents iterator and error types created by these methods
77//! (rarely useful).
78//!
79//! Note the documentation for the primitives [`str`] and [`[T]`][prim@slice] (also
80//! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
81//! calls to methods on [`str`] and [`[T]`][prim@slice] respectively, via [deref
82//! coercions][deref-coercions].
83//!
84//! Third, the standard library defines [The Rust Prelude], a small collection
85//! of items - mostly traits - that are imported into every module of every
86//! crate. The traits in the prelude are pervasive, making the prelude
87//! documentation a good entry point to learning about the library.
88//!
89//! And finally, the standard library exports a number of standard macros, and
90//! [lists them on this page](#macros) (technically, not all of the standard
91//! macros are defined by the standard library - some are defined by the
92//! compiler - but they are documented here the same). Like the prelude, the
93//! standard macros are imported by default into all crates.
94//!
95//! # Contributing changes to the documentation
96//!
97//! Check out the Rust contribution guidelines [here](
98//! https://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation).
99//! The source for this documentation can be found on
100//! [GitHub](https://github.com/rust-lang/rust) in the 'library/std/' directory.
101//! To contribute changes, make sure you read the guidelines first, then submit
102//! pull-requests for your suggested changes.
103//!
104//! Contributions are appreciated! If you see a part of the docs that can be
105//! improved, submit a PR, or chat with us first on [Zulip][t-libs-zulip]
106//! #t-libs.
107//!
108//! # A Tour of The Rust Standard Library
109//!
110//! The rest of this crate documentation is dedicated to pointing out notable
111//! features of The Rust Standard Library.
112//!
113//! ## Containers and collections
114//!
115//! The [`option`] and [`result`] modules define optional and error-handling
116//! types, [`Option<T>`] and [`Result<T, E>`]. The [`iter`] module defines
117//! Rust's iterator trait, [`Iterator`], which works with the [`for`] loop to
118//! access collections.
119//!
120//! The standard library exposes three common ways to deal with contiguous
121//! regions of memory:
122//!
123//! * [`Vec<T>`] - A heap-allocated *vector* that is resizable at runtime.
124//! * [`[T; N]`][prim@array] - An inline *array* with a fixed size at compile time.
125//! * [`[T]`][prim@slice] - A dynamically sized *slice* into any other kind of contiguous
126//!   storage, whether heap-allocated or not.
127//!
128//! Slices can only be handled through some kind of *pointer*, and as such come
129//! in many flavors such as:
130//!
131//! * `&[T]` - *shared slice*
132//! * `&mut [T]` - *mutable slice*
133//! * [`Box<[T]>`][owned slice] - *owned slice*
134//!
135//! [`str`], a UTF-8 string slice, is a primitive type, and the standard library
136//! defines many methods for it. Rust [`str`]s are typically accessed as
137//! immutable references: `&str`. Use the owned [`String`] for building and
138//! mutating strings.
139//!
140//! For converting to strings use the [`format!`] macro, and for converting from
141//! strings use the [`FromStr`] trait.
142//!
143//! Data may be shared by placing it in a reference-counted box or the [`Rc`]
144//! type, and if further contained in a [`Cell`] or [`RefCell`], may be mutated
145//! as well as shared. Likewise, in a concurrent setting it is common to pair an
146//! atomically-reference-counted box, [`Arc`], with a [`Mutex`] to get the same
147//! effect.
148//!
149//! The [`collections`] module defines maps, sets, linked lists and other
150//! typical collection types, including the common [`HashMap<K, V>`].
151//!
152//! ## Platform abstractions and I/O
153//!
154//! Besides basic data types, the standard library is largely concerned with
155//! abstracting over differences in common platforms, most notably Windows and
156//! Unix derivatives.
157//!
158//! Common types of I/O, including [files], [TCP], and [UDP], are defined in
159//! the [`io`], [`fs`], and [`net`] modules.
160//!
161//! The [`thread`] module contains Rust's threading abstractions. [`sync`]
162//! contains further primitive shared memory types, including [`atomic`], [`mpmc`] and
163//! [`mpsc`], which contains the channel types for message passing.
164//!
165//! # Use before and after `main()`
166//!
167//! Many parts of the standard library are expected to work before and after `main()`;
168//! but this is not guaranteed or ensured by tests. It is recommended that you write your own tests
169//! and run them on each platform you wish to support.
170//! This means that use of `std` before/after main, especially of features that interact with the
171//! OS or global state, is exempted from stability and portability guarantees and instead only
172//! provided on a best-effort basis. Nevertheless bug reports are appreciated.
173//!
174//! On the other hand `core` and `alloc` are most likely to work in such environments with
175//! the caveat that any hookable behavior such as panics, oom handling or allocators will also
176//! depend on the compatibility of the hooks.
177//!
178//! Some features may also behave differently outside main, e.g. stdio could become unbuffered,
179//! some panics might turn into aborts, backtraces might not get symbolicated or similar.
180//!
181//! Non-exhaustive list of known limitations:
182//!
183//! - after-main use of thread-locals, which also affects additional features:
184//!   - [`thread::current()`]
185//! - under UNIX, before main, file descriptors 0, 1, and 2 may be unchanged
186//!   (they are guaranteed to be open during main,
187//!    and are opened to /dev/null O_RDWR if they weren't open on program start)
188//!
189//!
190//! [I/O]: io
191//! [TCP]: net::TcpStream
192//! [The Rust Prelude]: prelude
193//! [UDP]: net::UdpSocket
194//! [`Arc`]: sync::Arc
195//! [owned slice]: boxed
196//! [`Cell`]: cell::Cell
197//! [`FromStr`]: str::FromStr
198//! [`HashMap<K, V>`]: collections::HashMap
199//! [`Mutex`]: sync::Mutex
200//! [`Option<T>`]: option::Option
201//! [`Rc`]: rc::Rc
202//! [`RefCell`]: cell::RefCell
203//! [`Result<T, E>`]: result::Result
204//! [`Vec<T>`]: vec::Vec
205//! [`atomic`]: sync::atomic
206//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
207//! [`str`]: prim@str
208//! [`mpmc`]: sync::mpmc
209//! [`mpsc`]: sync::mpsc
210//! [`std::cmp`]: cmp
211//! [`std::slice`]: mod@slice
212//! [`use std::env`]: env/index.html
213//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
214//! [crates.io]: https://crates.io
215//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
216//! [files]: fs::File
217//! [multithreading]: thread
218//! [other]: #what-is-in-the-standard-library-documentation
219//! [primitive types]: ../book/ch03-02-data-types.html
220//! [t-libs-zulip]: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/
221//! [array]: prim@array
222//! [slice]: prim@slice
223
224#![cfg_attr(not(restricted_std), stable(feature = "rust1", since = "1.0.0"))]
225#![cfg_attr(
226    restricted_std,
227    unstable(
228        feature = "restricted_std",
229        issue = "none",
230        reason = "You have attempted to use a standard library built for a platform that it doesn't \
231            know how to support. Consider building it for a known environment, disabling it with \
232            `#![no_std]` or overriding this warning by enabling this feature."
233    )
234)]
235#![rustc_preserve_ub_checks]
236#![doc(
237    html_root_url = "https://edp.fortanix.com/docs/api/",
238    html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg",
239    html_favicon_url = "https://edp.fortanix.com/favicon.ico",
240    html_playground_url = "https://play.rust-lang.org/",
241    issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
242    test(no_crate_inject, attr(deny(warnings))),
243    test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
244)]
245#![doc(rust_logo)]
246#![doc(auto_cfg(hide(no_global_oom_handling)))]
247// Don't link to std. We are std.
248#![no_std]
249// Tell the compiler to link to either panic_abort or panic_unwind
250#![needs_panic_runtime]
251//
252// Lints:
253#![warn(deprecated_in_future)]
254#![warn(missing_docs)]
255#![warn(unreachable_pub)]
256#![warn(missing_debug_implementations)]
257#![allow(explicit_outlives_requirements)]
258#![allow(internal_features)]
259#![deny(implicit_provenance_casts)]
260#![deny(unsafe_op_in_unsafe_fn)]
261#![allow(rustdoc::redundant_explicit_links)]
262#![warn(rustdoc::unescaped_backticks)]
263// Ensure that std can be linked against panic_abort despite compiled with `-C panic=unwind`
264#![deny(ffi_unwind_calls)]
265// std may use features in a platform-specific way
266#![allow(unused_features)]
267//
268// Features:
269#![cfg_attr(
270    test,
271    feature(internal_output_capture, print_internals, super_let, update_panic_count, rt)
272)]
273#![cfg_attr(
274    all(target_vendor = "fortanix", target_env = "sgx"),
275    feature(slice_index_methods, coerce_unsized, sgx_platform)
276)]
277#![cfg_attr(all(test, target_os = "uefi"), feature(uefi_std))]
278#![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
279#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
280//
281// Language features:
282// tidy-alphabetical-start
283#![feature(alloc_error_handler)]
284#![feature(allocator_internals)]
285#![feature(allow_internal_unsafe)]
286#![feature(allow_internal_unstable)]
287#![feature(asm_experimental_arch)]
288#![feature(autodiff)]
289#![feature(cfg_sanitizer_cfi)]
290#![feature(cfg_target_has_threads)]
291#![feature(cfg_target_thread_local)]
292#![feature(cfi_encoding)]
293#![feature(const_trait_impl)]
294#![feature(decl_macro)]
295#![feature(deprecated_suggestion)]
296#![feature(diagnostic_on_move)]
297#![feature(doc_cfg)]
298#![feature(doc_masked)]
299#![feature(doc_notable_trait)]
300#![feature(dropck_eyepatch)]
301#![feature(f16)]
302#![feature(f128)]
303#![feature(ffi_const)]
304#![feature(gpu_offload)]
305#![feature(impl_restriction)]
306#![feature(intra_doc_pointers)]
307#![feature(lang_items)]
308#![feature(link_cfg)]
309#![feature(linkage)]
310#![feature(macro_metavar_expr_concat)]
311#![feature(min_specialization)]
312#![feature(must_not_suspend)]
313#![feature(needs_panic_runtime)]
314#![feature(negative_impls)]
315#![feature(prelude_import)]
316#![feature(rustc_attrs)]
317#![feature(rustdoc_internals)]
318#![feature(staged_api)]
319#![feature(stmt_expr_attributes)]
320#![feature(strict_provenance_lints)]
321#![feature(thread_local)]
322#![feature(try_blocks)]
323#![feature(try_trait_v2)]
324#![feature(type_alias_impl_trait)]
325// tidy-alphabetical-end
326//
327// Library features (core):
328// tidy-alphabetical-start
329#![feature(borrowed_buf_init)]
330#![feature(byte_str)]
331#![feature(byte_str_internals)]
332#![feature(c_size_t)]
333#![feature(can_vector)]
334#![feature(cast_maybe_uninit)]
335#![feature(char_internals)]
336#![feature(clone_to_uninit)]
337#![feature(const_clone)]
338#![feature(const_convert)]
339#![feature(const_default)]
340#![feature(core_float_math)]
341#![feature(core_intrinsics)]
342#![feature(core_io)]
343#![feature(core_io_borrowed_buf)]
344#![feature(core_io_internals)]
345#![feature(cursor_split)]
346#![feature(derive_const)]
347#![feature(duration_constants)]
348#![feature(error_generic_member_access)]
349#![feature(error_iter)]
350#![feature(exact_size_is_empty)]
351#![feature(extend_one)]
352#![feature(float_gamma)]
353#![feature(float_minimum_maximum)]
354#![feature(fmt_internals)]
355#![feature(fn_static)]
356#![feature(formatting_options)]
357#![feature(generic_atomic)]
358#![feature(hash_map_internals)]
359#![feature(hash_map_macro)]
360#![feature(hasher_prefixfree_extras)]
361#![feature(hashmap_internals)]
362#![feature(hint_must_use)]
363#![feature(int_from_ascii)]
364#![feature(io_error_inprogress)]
365#![feature(io_error_input_output_error)]
366#![feature(io_error_more)]
367#![feature(io_error_too_many_open_files)]
368#![feature(io_error_uncategorized)]
369#![feature(io_slice_as_bytes)]
370#![feature(ip)]
371#![feature(ipv6_hop_limit)]
372#![feature(iter_advance_by)]
373#![feature(iter_next_chunk)]
374#![feature(maybe_dangling)]
375#![feature(maybe_uninit_array_assume_init)]
376#![feature(maybe_uninit_fill)]
377#![feature(once_lazy_lock_get_unchecked)]
378#![feature(panic_can_unwind)]
379#![feature(panic_internals)]
380#![feature(pin_coerce_unsized_trait)]
381#![feature(pointer_is_aligned_to)]
382#![feature(portable_simd)]
383#![feature(ptr_as_uninit)]
384#![feature(ptr_mask)]
385#![feature(random)]
386#![feature(raw_os_error_ty)]
387#![feature(register_tool)]
388#![feature(seek_io_take_position)]
389#![feature(seek_stream_len)]
390#![feature(share_trait)]
391#![feature(slice_internals)]
392#![feature(slice_ptr_get)]
393#![feature(slice_range)]
394#![feature(std_internals)]
395#![feature(str_internals)]
396#![feature(sync_unsafe_cell)]
397#![feature(temporary_niche_types)]
398#![feature(ub_checks)]
399#![feature(uint_carryless_mul)]
400#![feature(unsafe_pinned)]
401#![feature(used_with_arg)]
402#![feature(write_all_vectored)]
403// tidy-alphabetical-end
404//
405// Library features (alloc):
406// tidy-alphabetical-start
407#![feature(alloc_io)]
408#![feature(allocator_ext)]
409#![feature(buf_read_has_data_left)]
410#![feature(clone_from_ref)]
411#![feature(get_mut_unchecked)]
412#![feature(map_try_insert)]
413#![feature(read_buf)]
414#![feature(slice_concat_trait)]
415#![feature(thin_box)]
416#![feature(try_reserve_kind)]
417#![feature(try_with_capacity)]
418#![feature(unique_rc_arc)]
419#![feature(wtf8_internals)]
420// tidy-alphabetical-end
421//
422// Library features (unwind):
423// tidy-alphabetical-start
424#![feature(panic_unwind)]
425// tidy-alphabetical-end
426//
427// Library features (std_detect):
428// tidy-alphabetical-start
429#![feature(stdarch_internal)]
430// tidy-alphabetical-end
431//
432// Only for re-exporting:
433// tidy-alphabetical-start
434#![feature(async_iterator)]
435#![feature(cfg_accessible)]
436#![feature(cfg_eval)]
437#![feature(concat_bytes)]
438#![feature(const_format_args)]
439#![feature(custom_test_frameworks)]
440#![feature(edition_panic)]
441#![feature(format_args_nl)]
442#![feature(log_syntax)]
443#![feature(test)]
444#![feature(trace_macros)]
445// tidy-alphabetical-end
446//
447// Only used in tests/benchmarks:
448//
449// Only for const-ness:
450// tidy-alphabetical-start
451#![feature(io_const_error)]
452// tidy-alphabetical-end
453//
454#![default_lib_allocator]
455// Removed features
456#![unstable_removed(
457    feature = "concat_idents",
458    reason = "Replaced by the macro_metavar_expr_concat feature",
459    link = "https://github.com/rust-lang/rust/issues/29599#issuecomment-2986866250",
460    since = "1.90.0"
461)]
462// tidy-alphabetical-start
463#![register_tool(lint)]
464// tidy-alphabetical-end
465//
466
467// The Rust prelude
468// The compiler expects the prelude definition to be defined before its use statement.
469pub mod prelude;
470
471// Explicitly import the prelude. The compiler uses this same unstable attribute
472// to import the prelude implicitly when building crates that depend on std.
473#[prelude_import]
474#[allow(unused)]
475use prelude::rust_2024::*;
476
477// Access to Bencher, etc.
478#[cfg(test)]
479extern crate test;
480
481#[allow(unused_imports)] // macros from `alloc` are not used on all platforms
482#[macro_use]
483extern crate alloc as alloc_crate;
484
485// Many compiler tests depend on libc being pulled in by std
486// so include it here even if it's unused.
487#[doc(masked)]
488#[allow(unused_extern_crates)]
489#[cfg(not(all(windows, target_env = "msvc")))]
490extern crate libc;
491
492// We always need an unwinder currently for backtraces
493#[doc(masked)]
494#[allow(unused_extern_crates)]
495extern crate unwind;
496
497// FIXME: #94122 this extern crate definition only exist here to stop
498// miniz_oxide docs leaking into std docs. Find better way to do it.
499// Remove exclusion from tidy platform check when this removed.
500#[doc(masked)]
501#[allow(unused_extern_crates)]
502#[cfg(all(
503    not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))),
504    feature = "miniz_oxide"
505))]
506extern crate miniz_oxide;
507
508// During testing, this crate is not actually the "real" std library, but rather
509// it links to the real std library, which was compiled from this same source
510// code. So any lang items std defines are conditionally excluded (or else they
511// would generate duplicate lang item errors), and any globals it defines are
512// _not_ the globals used by "real" std. So this import, defined only during
513// testing gives test-std access to real-std lang items and globals. See #2912
514#[cfg(test)]
515extern crate std as realstd;
516
517// The standard macros that are not built-in to the compiler.
518#[macro_use]
519mod macros;
520
521// The runtime entry point and a few unstable public functions used by the
522// compiler
523#[macro_use]
524pub mod rt;
525
526#[stable(feature = "rust1", since = "1.0.0")]
527pub use core::any;
528#[stable(feature = "core_array", since = "1.35.0")]
529pub use core::array;
530#[unstable(feature = "async_iterator", issue = "79024")]
531pub use core::async_iter;
532#[stable(feature = "rust1", since = "1.0.0")]
533pub use core::cell;
534#[stable(feature = "rust1", since = "1.0.0")]
535pub use core::char;
536#[stable(feature = "rust1", since = "1.0.0")]
537pub use core::clone;
538#[stable(feature = "rust1", since = "1.0.0")]
539pub use core::cmp;
540#[stable(feature = "rust1", since = "1.0.0")]
541pub use core::convert;
542#[stable(feature = "rust1", since = "1.0.0")]
543pub use core::default;
544#[unstable(feature = "field_projections", issue = "145383")]
545pub use core::field;
546#[stable(feature = "futures_api", since = "1.36.0")]
547pub use core::future;
548#[stable(feature = "core_hint", since = "1.27.0")]
549pub use core::hint;
550#[stable(feature = "rust1", since = "1.0.0")]
551#[allow(deprecated, clippy::legacy_numeric_constants)]
552pub use core::i8;
553#[stable(feature = "rust1", since = "1.0.0")]
554#[allow(deprecated, clippy::legacy_numeric_constants)]
555pub use core::i16;
556#[stable(feature = "rust1", since = "1.0.0")]
557#[allow(deprecated, clippy::legacy_numeric_constants)]
558pub use core::i32;
559#[stable(feature = "rust1", since = "1.0.0")]
560#[allow(deprecated, clippy::legacy_numeric_constants)]
561pub use core::i64;
562#[stable(feature = "i128", since = "1.26.0")]
563#[allow(deprecated, clippy::legacy_numeric_constants)]
564pub use core::i128;
565#[stable(feature = "rust1", since = "1.0.0")]
566pub use core::intrinsics;
567#[stable(feature = "rust1", since = "1.0.0")]
568#[allow(deprecated, clippy::legacy_numeric_constants)]
569pub use core::isize;
570#[stable(feature = "rust1", since = "1.0.0")]
571pub use core::iter;
572#[stable(feature = "rust1", since = "1.0.0")]
573pub use core::marker;
574#[stable(feature = "rust1", since = "1.0.0")]
575pub use core::mem;
576#[stable(feature = "rust1", since = "1.0.0")]
577pub use core::ops;
578#[stable(feature = "rust1", since = "1.0.0")]
579pub use core::option;
580#[stable(feature = "pin", since = "1.33.0")]
581pub use core::pin;
582#[stable(feature = "rust1", since = "1.0.0")]
583pub use core::ptr;
584#[stable(feature = "new_range_api", since = "1.96.0")]
585pub use core::range;
586#[stable(feature = "rust1", since = "1.0.0")]
587pub use core::result;
588#[stable(feature = "rust1", since = "1.0.0")]
589#[allow(deprecated, clippy::legacy_numeric_constants)]
590pub use core::u8;
591#[stable(feature = "rust1", since = "1.0.0")]
592#[allow(deprecated, clippy::legacy_numeric_constants)]
593pub use core::u16;
594#[stable(feature = "rust1", since = "1.0.0")]
595#[allow(deprecated, clippy::legacy_numeric_constants)]
596pub use core::u32;
597#[stable(feature = "rust1", since = "1.0.0")]
598#[allow(deprecated, clippy::legacy_numeric_constants)]
599pub use core::u64;
600#[stable(feature = "i128", since = "1.26.0")]
601#[allow(deprecated, clippy::legacy_numeric_constants)]
602pub use core::u128;
603#[unstable(feature = "unsafe_binders", issue = "130516")]
604pub use core::unsafe_binder;
605#[stable(feature = "rust1", since = "1.0.0")]
606#[allow(deprecated, clippy::legacy_numeric_constants)]
607pub use core::usize;
608
609#[stable(feature = "rust1", since = "1.0.0")]
610pub use alloc_crate::borrow;
611#[stable(feature = "rust1", since = "1.0.0")]
612pub use alloc_crate::boxed;
613#[stable(feature = "rust1", since = "1.0.0")]
614pub use alloc_crate::fmt;
615#[stable(feature = "rust1", since = "1.0.0")]
616pub use alloc_crate::format;
617#[stable(feature = "rust1", since = "1.0.0")]
618pub use alloc_crate::rc;
619#[stable(feature = "rust1", since = "1.0.0")]
620pub use alloc_crate::slice;
621#[stable(feature = "rust1", since = "1.0.0")]
622pub use alloc_crate::str;
623#[stable(feature = "rust1", since = "1.0.0")]
624pub use alloc_crate::string;
625#[stable(feature = "rust1", since = "1.0.0")]
626pub use alloc_crate::vec;
627
628#[path = "num/f128.rs"]
629pub mod f128;
630#[path = "num/f16.rs"]
631pub mod f16;
632#[path = "num/f32.rs"]
633pub mod f32;
634#[path = "num/f64.rs"]
635pub mod f64;
636
637#[macro_use]
638pub mod thread;
639pub mod ascii;
640pub mod backtrace;
641#[unstable(feature = "byte_str", issue = "134915")]
642pub mod byte_str;
643pub mod collections;
644pub mod env;
645pub mod error;
646pub mod ffi;
647pub mod fs;
648pub mod hash;
649pub mod io;
650pub mod net;
651pub mod num;
652#[allow(unreachable_pub)]
653pub mod os;
654pub mod panic;
655#[unstable(feature = "pattern_type_macro", issue = "123646")]
656pub mod pat;
657pub mod path;
658pub mod process;
659#[unstable(feature = "random", issue = "130703")]
660pub mod random;
661pub mod sync;
662pub mod time;
663#[unstable(feature = "view_type_macro", issue = "155938")]
664pub mod view;
665
666// Pull in `std_float` crate  into std. The contents of
667// `std_float` are in a different repository: rust-lang/portable-simd.
668#[path = "../../portable-simd/crates/std_float/src/lib.rs"]
669#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn)]
670#[allow(rustdoc::bare_urls)]
671#[unstable(feature = "portable_simd", issue = "86656")]
672mod std_float;
673
674#[unstable(feature = "portable_simd", issue = "86656")]
675pub mod simd {
676    #![doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
677
678    #[doc(inline)]
679    pub use core::simd::*;
680
681    #[doc(inline)]
682    pub use crate::std_float::StdFloat;
683}
684
685#[unstable(feature = "autodiff", issue = "124509")]
686#[doc = include_str!("../../core/src/autodiff.md")]
687pub mod autodiff {
688    /// This macro handles automatic differentiation.
689    pub use core::autodiff::{autodiff_forward, autodiff_reverse};
690}
691
692#[unstable(feature = "gpu_offload", issue = "131513")]
693#[doc = include_str!("../../core/src/offload.md")]
694pub mod offload {
695    pub use core::offload::{offload, offload_kernel};
696}
697
698#[stable(feature = "futures_api", since = "1.36.0")]
699pub mod task {
700    //! Types and Traits for working with asynchronous tasks.
701
702    #[doc(inline)]
703    #[stable(feature = "wake_trait", since = "1.51.0")]
704    pub use alloc::task::*;
705    #[doc(inline)]
706    #[stable(feature = "futures_api", since = "1.36.0")]
707    pub use core::task::*;
708}
709
710#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
711#[stable(feature = "simd_arch", since = "1.27.0")]
712pub mod arch {
713    #[stable(feature = "simd_arch", since = "1.27.0")]
714    // The `no_inline`-attribute is required to make the documentation of all
715    // targets available.
716    // See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
717    // more information.
718    #[doc(no_inline)] // Note (#82861): required for correct documentation
719    pub use core::arch::*;
720
721    #[stable(feature = "simd_aarch64", since = "1.60.0")]
722    pub use std_detect::is_aarch64_feature_detected;
723    #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")]
724    pub use std_detect::is_arm_feature_detected;
725    #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")]
726    pub use std_detect::is_loongarch_feature_detected;
727    #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
728    pub use std_detect::is_powerpc_feature_detected;
729    #[stable(feature = "riscv_ratified", since = "1.78.0")]
730    pub use std_detect::is_riscv_feature_detected;
731    #[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")]
732    pub use std_detect::is_s390x_feature_detected;
733    #[stable(feature = "simd_x86", since = "1.27.0")]
734    pub use std_detect::is_x86_feature_detected;
735    #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
736    pub use std_detect::{is_mips_feature_detected, is_mips64_feature_detected};
737}
738
739// This was stabilized in the crate root so we have to keep it there.
740#[stable(feature = "simd_x86", since = "1.27.0")]
741pub use std_detect::is_x86_feature_detected;
742
743#[allow(unreachable_pub)]
744mod sys;
745
746pub mod alloc;
747
748// Private support modules
749mod panicking;
750
751#[path = "../../backtrace/src/lib.rs"]
752#[allow(implicit_provenance_casts, unsafe_op_in_unsafe_fn)]
753#[allow(clippy::len_zero, clippy::needless_borrow, clippy::filter_map_next)] // FIXME
754mod backtrace_rs;
755
756#[stable(feature = "cfg_select", since = "1.95.0")]
757pub use core::cfg_select;
758#[unstable(
759    feature = "concat_bytes",
760    issue = "87555",
761    reason = "`concat_bytes` is not stable enough for use and is subject to change"
762)]
763pub use core::concat_bytes;
764#[allow(clippy::useless_attribute)]
765#[expect(
766    ineffective_unstable_reexports,
767    reason = "accepted as stable after accidental stabilization in 1.96, see #154645"
768)]
769#[unstable(feature = "derive_macro_global_path", issue = "154645")]
770pub use core::derive;
771#[unstable(feature = "gca_min_const_items", issue = "132980", implied_by = "gca_adts")]
772pub use core::gca;
773#[stable(feature = "matches_macro", since = "1.42.0")]
774pub use core::matches;
775#[stable(feature = "core_primitive", since = "1.43.0")]
776pub use core::primitive;
777#[stable(feature = "todo_macro", since = "1.40.0")]
778pub use core::todo;
779// Re-export built-in macros defined through core.
780#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
781pub use core::{
782    assert, cfg, column, compile_error, concat, const_format_args, env, file, format_args,
783    format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
784    stringify, trace_macros,
785};
786// Re-export macros defined in core.
787#[stable(feature = "rust1", since = "1.0.0")]
788#[expect(deprecated, reason = "`try! macro")]
789pub use core::{
790    assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, r#try, unimplemented,
791    unreachable, write, writeln,
792};
793#[stable(feature = "assert_matches", since = "1.96.0")]
794pub use core::{assert_matches, debug_assert_matches};
795
796// Re-export unstable derive macro defined through core.
797#[unstable(feature = "derive_from", issue = "144889")]
798/// Unstable module containing the unstable `From` derive macro.
799pub mod from {
800    #[unstable(feature = "derive_from", issue = "144889")]
801    pub use core::from::From;
802}
803
804// We include the following files here *again* (they are already included in libcore)
805// so that they show up in search results for the std crate, and to avoid breaking
806// existing links:
807
808// documentation for built-in attributes. Using `include!` because rustdoc
809// only looks for these modules at the crate level.
810include!("../../core/src/attribute_docs.rs");
811
812// Include a number of private modules that exist solely to provide
813// the rustdoc documentation for the existing keywords. Using `include!`
814// because rustdoc only looks for these modules at the crate level.
815include!("../../core/src/keyword_docs.rs");
816
817// Include a number of private modules that exist solely to provide
818// the rustdoc documentation for primitive types. Using `include!`
819// because rustdoc only looks for these modules at the crate level.
820include!("../../core/src/primitive_docs.rs");
821
822// This is required to avoid an unstable error when `restricted-std` is not
823// enabled. The use of #![feature(restricted_std)] in rustc-std-workspace-std
824// is unconditional, so the unstable feature needs to be defined somewhere.
825#[unstable(feature = "restricted_std", issue = "none")]
826mod __restricted_std_workaround {}
827
828#[cfg(test)]
829#[allow(dead_code)] // Not used in all configurations.
830pub(crate) mod test_helpers;