]> git.lizzy.rs Git - rust.git/blob - library/std/src/lib.rs
Auto merge of #99487 - bmacnaughton:is_whitespace_updates, r=thomcc
[rust.git] / library / std / src / lib.rs
1 //! # The Rust Standard Library
2 //!
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 //!
10 //! `std` is available to all Rust crates by default. Therefore, the
11 //! standard library can be accessed in [`use`] statements through the path
12 //! `std`, as in [`use std::env`].
13 //!
14 //! # How to read this documentation
15 //!
16 //! If you already know the name of what you are looking for, the fastest way to
17 //! find it is to use the <a href="#" onclick="focusSearchBar();">search
18 //! bar</a> at the top of the page.
19 //!
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]
26 //!
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!
32 //!
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
35 //! development you may want to press the `[-]` button near the top of the
36 //! page to collapse it into a more skimmable view.
37 //!
38 //! While you are looking at that `[-]` button also notice the `source`
39 //! link. 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.
42 //!
43 //! # What is in the standard library documentation?
44 //!
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.
51 //!
52 //! Second, implicit methods on [primitive types] are documented here. This can
53 //! be a source of confusion for two reasons:
54 //!
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.
62 //!
63 //! So for example there is a [page for the primitive type
64 //! `i32`](primitive::i32) 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`] that documents the constant values [`MIN`] and [`MAX`] (rarely
67 //! useful).
68 //!
69 //! Note the documentation for the primitives [`str`] and [`[T]`][prim@slice] (also
70 //! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
71 //! calls to methods on [`str`] and [`[T]`][prim@slice] respectively, via [deref
72 //! coercions][deref-coercions].
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
77 //! documentation a good entry point to learning about the library.
78 //!
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.
84 //!
85 //! # Contributing changes to the documentation
86 //!
87 //! Check out the rust contribution guidelines [here](
88 //! https://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation).
89 //! The source for this documentation can be found on
90 //! [GitHub](https://github.com/rust-lang/rust).
91 //! To contribute changes, make sure you read the guidelines first, then submit
92 //! pull-requests for your suggested changes.
93 //!
94 //! Contributions are appreciated! If you see a part of the docs that can be
95 //! improved, submit a PR, or chat with us first on [Discord][rust-discord]
96 //! #docs.
97 //!
98 //! # A Tour of The Rust Standard Library
99 //!
100 //! The rest of this crate documentation is dedicated to pointing out notable
101 //! features of The Rust Standard Library.
102 //!
103 //! ## Containers and collections
104 //!
105 //! The [`option`] and [`result`] modules define optional and error-handling
106 //! types, [`Option<T>`] and [`Result<T, E>`]. The [`iter`] module defines
107 //! Rust's iterator trait, [`Iterator`], which works with the [`for`] loop to
108 //! access collections.
109 //!
110 //! The standard library exposes three common ways to deal with contiguous
111 //! regions of memory:
112 //!
113 //! * [`Vec<T>`] - A heap-allocated *vector* that is resizable at runtime.
114 //! * [`[T; N]`][prim@array] - An inline *array* with a fixed size at compile time.
115 //! * [`[T]`][prim@slice] - A dynamically sized *slice* into any other kind of contiguous
116 //!   storage, whether heap-allocated or not.
117 //!
118 //! Slices can only be handled through some kind of *pointer*, and as such come
119 //! in many flavors such as:
120 //!
121 //! * `&[T]` - *shared slice*
122 //! * `&mut [T]` - *mutable slice*
123 //! * [`Box<[T]>`][owned slice] - *owned slice*
124 //!
125 //! [`str`], a UTF-8 string slice, is a primitive type, and the standard library
126 //! defines many methods for it. Rust [`str`]s are typically accessed as
127 //! immutable references: `&str`. Use the owned [`String`] for building and
128 //! mutating strings.
129 //!
130 //! For converting to strings use the [`format!`] macro, and for converting from
131 //! strings use the [`FromStr`] trait.
132 //!
133 //! Data may be shared by placing it in a reference-counted box or the [`Rc`]
134 //! type, and if further contained in a [`Cell`] or [`RefCell`], may be mutated
135 //! as well as shared. Likewise, in a concurrent setting it is common to pair an
136 //! atomically-reference-counted box, [`Arc`], with a [`Mutex`] to get the same
137 //! effect.
138 //!
139 //! The [`collections`] module defines maps, sets, linked lists and other
140 //! typical collection types, including the common [`HashMap<K, V>`].
141 //!
142 //! ## Platform abstractions and I/O
143 //!
144 //! Besides basic data types, the standard library is largely concerned with
145 //! abstracting over differences in common platforms, most notably Windows and
146 //! Unix derivatives.
147 //!
148 //! Common types of I/O, including [files], [TCP], [UDP], are defined in the
149 //! [`io`], [`fs`], and [`net`] modules.
150 //!
151 //! The [`thread`] module contains Rust's threading abstractions. [`sync`]
152 //! contains further primitive shared memory types, including [`atomic`] and
153 //! [`mpsc`], which contains the channel types for message passing.
154 //!
155 //! [I/O]: io
156 //! [`MIN`]: i32::MIN
157 //! [`MAX`]: i32::MAX
158 //! [page for the module `std::i32`]: crate::i32
159 //! [TCP]: net::TcpStream
160 //! [The Rust Prelude]: prelude
161 //! [UDP]: net::UdpSocket
162 //! [`Arc`]: sync::Arc
163 //! [owned slice]: boxed
164 //! [`Cell`]: cell::Cell
165 //! [`FromStr`]: str::FromStr
166 //! [`HashMap<K, V>`]: collections::HashMap
167 //! [`Mutex`]: sync::Mutex
168 //! [`Option<T>`]: option::Option
169 //! [`Rc`]: rc::Rc
170 //! [`RefCell`]: cell::RefCell
171 //! [`Result<T, E>`]: result::Result
172 //! [`Vec<T>`]: vec::Vec
173 //! [`atomic`]: sync::atomic
174 //! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
175 //! [`str`]: prim@str
176 //! [`mpsc`]: sync::mpsc
177 //! [`std::cmp`]: cmp
178 //! [`std::slice`]: mod@slice
179 //! [`use std::env`]: env/index.html
180 //! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
181 //! [crates.io]: https://crates.io
182 //! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
183 //! [files]: fs::File
184 //! [multithreading]: thread
185 //! [other]: #what-is-in-the-standard-library-documentation
186 //! [primitive types]: ../book/ch03-02-data-types.html
187 //! [rust-discord]: https://discord.gg/rust-lang
188 //! [array]: prim@array
189 //! [slice]: prim@slice
190
191 #![cfg_attr(not(feature = "restricted-std"), stable(feature = "rust1", since = "1.0.0"))]
192 #![cfg_attr(feature = "restricted-std", unstable(feature = "restricted_std", issue = "none"))]
193 #![doc(
194     html_playground_url = "https://play.rust-lang.org/",
195     issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
196     test(no_crate_inject, attr(deny(warnings))),
197     test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
198 )]
199 #![doc(cfg_hide(
200     not(test),
201     not(any(test, bootstrap)),
202     no_global_oom_handling,
203     not(no_global_oom_handling)
204 ))]
205 // To run libstd tests without x.py without ending up with two copies of libstd, Miri needs to be
206 // able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
207 // rustc itself never sets the feature, so this line has no affect there.
208 #![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
209 // miri-test-libstd also prefers to make std use the sysroot versions of the dependencies.
210 #![cfg_attr(feature = "miri-test-libstd", feature(rustc_private))]
211 // Don't link to std. We are std.
212 #![no_std]
213 // Tell the compiler to link to either panic_abort or panic_unwind
214 #![needs_panic_runtime]
215 //
216 // Lints:
217 #![warn(deprecated_in_future)]
218 #![warn(missing_docs)]
219 #![warn(missing_debug_implementations)]
220 #![allow(explicit_outlives_requirements)]
221 #![allow(unused_lifetimes)]
222 #![deny(rustc::existing_doc_keyword)]
223 // Ensure that std can be linked against panic_abort despite compiled with `-C panic=unwind`
224 #![deny(ffi_unwind_calls)]
225 // std may use features in a platform-specific way
226 #![allow(unused_features)]
227 //
228 // Features:
229 #![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))]
230 #![cfg_attr(
231     all(target_vendor = "fortanix", target_env = "sgx"),
232     feature(slice_index_methods, coerce_unsized, sgx_platform)
233 )]
234 //
235 // Language features:
236 #![feature(alloc_error_handler)]
237 #![feature(allocator_internals)]
238 #![feature(allow_internal_unsafe)]
239 #![feature(allow_internal_unstable)]
240 #![feature(box_syntax)]
241 #![feature(c_unwind)]
242 #![feature(cfg_target_thread_local)]
243 #![feature(concat_idents)]
244 #![feature(const_mut_refs)]
245 #![feature(const_trait_impl)]
246 #![feature(decl_macro)]
247 #![feature(deprecated_suggestion)]
248 #![feature(doc_cfg)]
249 #![feature(doc_cfg_hide)]
250 #![feature(doc_masked)]
251 #![feature(doc_notable_trait)]
252 #![feature(dropck_eyepatch)]
253 #![feature(exhaustive_patterns)]
254 #![feature(intra_doc_pointers)]
255 #![cfg_attr(bootstrap, feature(label_break_value))]
256 #![feature(lang_items)]
257 #![feature(let_else)]
258 #![feature(linkage)]
259 #![feature(link_cfg)]
260 #![feature(min_specialization)]
261 #![feature(must_not_suspend)]
262 #![feature(needs_panic_runtime)]
263 #![feature(negative_impls)]
264 #![feature(never_type)]
265 #![feature(platform_intrinsics)]
266 #![feature(prelude_import)]
267 #![feature(rustc_attrs)]
268 #![feature(rustdoc_internals)]
269 #![feature(staged_api)]
270 #![feature(thread_local)]
271 #![feature(try_blocks)]
272 #![feature(utf8_chunks)]
273 //
274 // Library features (core):
275 #![feature(array_error_internals)]
276 #![feature(atomic_mut_ptr)]
277 #![feature(char_error_internals)]
278 #![feature(char_internals)]
279 #![feature(core_intrinsics)]
280 #![feature(cstr_from_bytes_until_nul)]
281 #![feature(cstr_internals)]
282 #![feature(duration_checked_float)]
283 #![feature(duration_constants)]
284 #![cfg_attr(not(bootstrap), feature(error_generic_member_access))]
285 #![cfg_attr(not(bootstrap), feature(error_in_core))]
286 #![cfg_attr(not(bootstrap), feature(error_iter))]
287 #![feature(exact_size_is_empty)]
288 #![feature(exclusive_wrapper)]
289 #![feature(extend_one)]
290 #![feature(float_minimum_maximum)]
291 #![feature(hasher_prefixfree_extras)]
292 #![feature(hashmap_internals)]
293 #![feature(int_error_internals)]
294 #![feature(is_some_with)]
295 #![feature(maybe_uninit_slice)]
296 #![feature(maybe_uninit_write_slice)]
297 #![feature(mixed_integer_ops)]
298 #![feature(nonnull_slice_from_raw_parts)]
299 #![feature(panic_can_unwind)]
300 #![feature(panic_info_message)]
301 #![feature(panic_internals)]
302 #![feature(pointer_is_aligned)]
303 #![feature(portable_simd)]
304 #![feature(prelude_2024)]
305 #![feature(provide_any)]
306 #![feature(ptr_as_uninit)]
307 #![feature(raw_os_nonzero)]
308 #![feature(slice_internals)]
309 #![feature(slice_ptr_get)]
310 #![feature(std_internals)]
311 #![feature(str_internals)]
312 #![feature(strict_provenance)]
313 #![feature(maybe_uninit_uninit_array)]
314 #![feature(const_maybe_uninit_uninit_array)]
315 //
316 // Library features (alloc):
317 #![feature(alloc_layout_extra)]
318 #![feature(allocator_api)]
319 #![feature(get_mut_unchecked)]
320 #![feature(map_try_insert)]
321 #![feature(new_uninit)]
322 #![feature(thin_box)]
323 #![feature(try_reserve_kind)]
324 #![feature(vec_into_raw_parts)]
325 #![feature(slice_concat_trait)]
326 //
327 // Library features (unwind):
328 #![feature(panic_unwind)]
329 //
330 // Only for re-exporting:
331 #![feature(assert_matches)]
332 #![feature(async_iterator)]
333 #![feature(c_variadic)]
334 #![feature(cfg_accessible)]
335 #![feature(cfg_eval)]
336 #![feature(concat_bytes)]
337 #![feature(const_format_args)]
338 #![feature(core_panic)]
339 #![feature(custom_test_frameworks)]
340 #![feature(edition_panic)]
341 #![feature(format_args_nl)]
342 #![feature(log_syntax)]
343 #![feature(once_cell)]
344 #![feature(saturating_int_impl)]
345 #![feature(stdsimd)]
346 #![feature(test)]
347 #![feature(trace_macros)]
348 //
349 // Only used in tests/benchmarks:
350 #![feature(bench_black_box)]
351 //
352 // Only for const-ness:
353 #![feature(const_io_structs)]
354 #![feature(const_ip)]
355 #![feature(const_ipv4)]
356 #![feature(const_ipv6)]
357 #![feature(const_socketaddr)]
358 #![feature(thread_local_internals)]
359 //
360 #![default_lib_allocator]
361
362 // Explicitly import the prelude. The compiler uses this same unstable attribute
363 // to import the prelude implicitly when building crates that depend on std.
364 #[prelude_import]
365 #[allow(unused)]
366 use prelude::rust_2021::*;
367
368 // Access to Bencher, etc.
369 #[cfg(test)]
370 extern crate test;
371
372 #[allow(unused_imports)] // macros from `alloc` are not used on all platforms
373 #[macro_use]
374 extern crate alloc as alloc_crate;
375 #[doc(masked)]
376 #[allow(unused_extern_crates)]
377 extern crate libc;
378
379 // We always need an unwinder currently for backtraces
380 #[doc(masked)]
381 #[allow(unused_extern_crates)]
382 extern crate unwind;
383
384 #[doc(masked)]
385 #[allow(unused_extern_crates)]
386 #[cfg(feature = "miniz_oxide")]
387 extern crate miniz_oxide;
388
389 // During testing, this crate is not actually the "real" std library, but rather
390 // it links to the real std library, which was compiled from this same source
391 // code. So any lang items std defines are conditionally excluded (or else they
392 // would generate duplicate lang item errors), and any globals it defines are
393 // _not_ the globals used by "real" std. So this import, defined only during
394 // testing gives test-std access to real-std lang items and globals. See #2912
395 #[cfg(test)]
396 extern crate std as realstd;
397
398 // The standard macros that are not built-in to the compiler.
399 #[macro_use]
400 mod macros;
401
402 // The runtime entry point and a few unstable public functions used by the
403 // compiler
404 #[macro_use]
405 pub mod rt;
406
407 // The Rust prelude
408 pub mod prelude;
409
410 // Public module declarations and re-exports
411 #[stable(feature = "rust1", since = "1.0.0")]
412 pub use alloc_crate::borrow;
413 #[stable(feature = "rust1", since = "1.0.0")]
414 pub use alloc_crate::boxed;
415 #[stable(feature = "rust1", since = "1.0.0")]
416 pub use alloc_crate::fmt;
417 #[stable(feature = "rust1", since = "1.0.0")]
418 pub use alloc_crate::format;
419 #[stable(feature = "rust1", since = "1.0.0")]
420 pub use alloc_crate::rc;
421 #[stable(feature = "rust1", since = "1.0.0")]
422 pub use alloc_crate::slice;
423 #[stable(feature = "rust1", since = "1.0.0")]
424 pub use alloc_crate::str;
425 #[stable(feature = "rust1", since = "1.0.0")]
426 pub use alloc_crate::string;
427 #[stable(feature = "rust1", since = "1.0.0")]
428 pub use alloc_crate::vec;
429 #[stable(feature = "rust1", since = "1.0.0")]
430 pub use core::any;
431 #[stable(feature = "core_array", since = "1.36.0")]
432 pub use core::array;
433 #[unstable(feature = "async_iterator", issue = "79024")]
434 pub use core::async_iter;
435 #[stable(feature = "rust1", since = "1.0.0")]
436 pub use core::cell;
437 #[stable(feature = "rust1", since = "1.0.0")]
438 pub use core::char;
439 #[stable(feature = "rust1", since = "1.0.0")]
440 pub use core::clone;
441 #[stable(feature = "rust1", since = "1.0.0")]
442 pub use core::cmp;
443 #[stable(feature = "rust1", since = "1.0.0")]
444 pub use core::convert;
445 #[stable(feature = "rust1", since = "1.0.0")]
446 pub use core::default;
447 #[stable(feature = "futures_api", since = "1.36.0")]
448 pub use core::future;
449 #[stable(feature = "rust1", since = "1.0.0")]
450 pub use core::hash;
451 #[stable(feature = "core_hint", since = "1.27.0")]
452 pub use core::hint;
453 #[stable(feature = "i128", since = "1.26.0")]
454 #[allow(deprecated, deprecated_in_future)]
455 pub use core::i128;
456 #[stable(feature = "rust1", since = "1.0.0")]
457 #[allow(deprecated, deprecated_in_future)]
458 pub use core::i16;
459 #[stable(feature = "rust1", since = "1.0.0")]
460 #[allow(deprecated, deprecated_in_future)]
461 pub use core::i32;
462 #[stable(feature = "rust1", since = "1.0.0")]
463 #[allow(deprecated, deprecated_in_future)]
464 pub use core::i64;
465 #[stable(feature = "rust1", since = "1.0.0")]
466 #[allow(deprecated, deprecated_in_future)]
467 pub use core::i8;
468 #[stable(feature = "rust1", since = "1.0.0")]
469 pub use core::intrinsics;
470 #[stable(feature = "rust1", since = "1.0.0")]
471 #[allow(deprecated, deprecated_in_future)]
472 pub use core::isize;
473 #[stable(feature = "rust1", since = "1.0.0")]
474 pub use core::iter;
475 #[stable(feature = "rust1", since = "1.0.0")]
476 pub use core::marker;
477 #[stable(feature = "rust1", since = "1.0.0")]
478 pub use core::mem;
479 #[stable(feature = "rust1", since = "1.0.0")]
480 pub use core::ops;
481 #[stable(feature = "rust1", since = "1.0.0")]
482 pub use core::option;
483 #[stable(feature = "pin", since = "1.33.0")]
484 pub use core::pin;
485 #[stable(feature = "rust1", since = "1.0.0")]
486 pub use core::ptr;
487 #[stable(feature = "rust1", since = "1.0.0")]
488 pub use core::result;
489 #[stable(feature = "i128", since = "1.26.0")]
490 #[allow(deprecated, deprecated_in_future)]
491 pub use core::u128;
492 #[stable(feature = "rust1", since = "1.0.0")]
493 #[allow(deprecated, deprecated_in_future)]
494 pub use core::u16;
495 #[stable(feature = "rust1", since = "1.0.0")]
496 #[allow(deprecated, deprecated_in_future)]
497 pub use core::u32;
498 #[stable(feature = "rust1", since = "1.0.0")]
499 #[allow(deprecated, deprecated_in_future)]
500 pub use core::u64;
501 #[stable(feature = "rust1", since = "1.0.0")]
502 #[allow(deprecated, deprecated_in_future)]
503 pub use core::u8;
504 #[stable(feature = "rust1", since = "1.0.0")]
505 #[allow(deprecated, deprecated_in_future)]
506 pub use core::usize;
507
508 pub mod f32;
509 pub mod f64;
510
511 #[macro_use]
512 pub mod thread;
513 pub mod ascii;
514 pub mod backtrace;
515 pub mod collections;
516 pub mod env;
517 pub mod error;
518 pub mod ffi;
519 pub mod fs;
520 pub mod io;
521 pub mod net;
522 pub mod num;
523 pub mod os;
524 pub mod panic;
525 pub mod path;
526 pub mod process;
527 pub mod sync;
528 pub mod time;
529
530 #[unstable(feature = "once_cell", issue = "74465")]
531 pub mod lazy;
532
533 // Pull in `std_float` crate  into libstd. The contents of
534 // `std_float` are in a different repository: rust-lang/portable-simd.
535 #[path = "../../portable-simd/crates/std_float/src/lib.rs"]
536 #[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
537 #[allow(rustdoc::bare_urls)]
538 #[unstable(feature = "portable_simd", issue = "86656")]
539 mod std_float;
540
541 #[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
542 #[unstable(feature = "portable_simd", issue = "86656")]
543 pub mod simd {
544     #[doc(inline)]
545     pub use crate::std_float::StdFloat;
546     #[doc(inline)]
547     pub use core::simd::*;
548 }
549
550 #[stable(feature = "futures_api", since = "1.36.0")]
551 pub mod task {
552     //! Types and Traits for working with asynchronous tasks.
553
554     #[doc(inline)]
555     #[stable(feature = "futures_api", since = "1.36.0")]
556     pub use core::task::*;
557
558     #[doc(inline)]
559     #[stable(feature = "wake_trait", since = "1.51.0")]
560     pub use alloc::task::*;
561 }
562
563 #[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
564 #[stable(feature = "simd_arch", since = "1.27.0")]
565 pub mod arch {
566     #[stable(feature = "simd_arch", since = "1.27.0")]
567     // The `no_inline`-attribute is required to make the documentation of all
568     // targets available.
569     // See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
570     // more information.
571     #[doc(no_inline)] // Note (#82861): required for correct documentation
572     pub use core::arch::*;
573
574     #[stable(feature = "simd_aarch64", since = "1.60.0")]
575     pub use std_detect::is_aarch64_feature_detected;
576     #[stable(feature = "simd_x86", since = "1.27.0")]
577     pub use std_detect::is_x86_feature_detected;
578     #[unstable(feature = "stdsimd", issue = "48556")]
579     pub use std_detect::{
580         is_arm_feature_detected, is_mips64_feature_detected, is_mips_feature_detected,
581         is_powerpc64_feature_detected, is_powerpc_feature_detected, is_riscv_feature_detected,
582     };
583 }
584
585 // This was stabilized in the crate root so we have to keep it there.
586 #[stable(feature = "simd_x86", since = "1.27.0")]
587 pub use std_detect::is_x86_feature_detected;
588
589 // Platform-abstraction modules
590 mod sys;
591 mod sys_common;
592
593 pub mod alloc;
594
595 // Private support modules
596 mod panicking;
597
598 #[path = "../../backtrace/src/lib.rs"]
599 #[allow(dead_code, unused_attributes)]
600 mod backtrace_rs;
601
602 // Re-export macros defined in libcore.
603 #[stable(feature = "rust1", since = "1.0.0")]
604 #[allow(deprecated, deprecated_in_future)]
605 pub use core::{
606     assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try,
607     unimplemented, unreachable, write, writeln,
608 };
609
610 // Re-export built-in macros defined through libcore.
611 #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
612 #[allow(deprecated)]
613 pub use core::{
614     assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
615     env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
616     module_path, option_env, stringify, trace_macros,
617 };
618
619 #[unstable(
620     feature = "concat_bytes",
621     issue = "87555",
622     reason = "`concat_bytes` is not stable enough for use and is subject to change"
623 )]
624 pub use core::concat_bytes;
625
626 #[stable(feature = "core_primitive", since = "1.43.0")]
627 pub use core::primitive;
628
629 // Include a number of private modules that exist solely to provide
630 // the rustdoc documentation for primitive types. Using `include!`
631 // because rustdoc only looks for these modules at the crate level.
632 include!("primitive_docs.rs");
633
634 // Include a number of private modules that exist solely to provide
635 // the rustdoc documentation for the existing keywords. Using `include!`
636 // because rustdoc only looks for these modules at the crate level.
637 include!("keyword_docs.rs");
638
639 // This is required to avoid an unstable error when `restricted-std` is not
640 // enabled. The use of #![feature(restricted_std)] in rustc-std-workspace-std
641 // is unconditional, so the unstable feature needs to be defined somewhere.
642 #[unstable(feature = "restricted_std", issue = "none")]
643 mod __restricted_std_workaround {}
644
645 mod sealed {
646     /// This trait being unreachable from outside the crate
647     /// prevents outside implementations of our extension traits.
648     /// This allows adding more trait methods in the future.
649     #[unstable(feature = "sealed", issue = "none")]
650     pub trait Sealed {}
651 }