]> git.lizzy.rs Git - rust.git/blob - library/std/src/lib.rs
3a1f2c953448ec762df1d9d86a440b54941d75d5
[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 #![cfg_attr(not(feature = "restricted-std"), stable(feature = "rust1", since = "1.0.0"))]
191 #![cfg_attr(feature = "restricted-std", unstable(feature = "restricted_std", issue = "none"))]
192 #![doc(
193     html_playground_url = "https://play.rust-lang.org/",
194     issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
195     test(no_crate_inject, attr(deny(warnings))),
196     test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
197 )]
198 #![doc(cfg_hide(
199     not(test),
200     not(any(test, bootstrap)),
201     no_global_oom_handling,
202     not(no_global_oom_handling)
203 ))]
204 // Don't link to std. We are std.
205 #![no_std]
206 #![warn(deprecated_in_future)]
207 #![warn(missing_docs)]
208 #![warn(missing_debug_implementations)]
209 #![allow(explicit_outlives_requirements)]
210 #![allow(unused_lifetimes)]
211 // Tell the compiler to link to either panic_abort or panic_unwind
212 #![needs_panic_runtime]
213 // std may use features in a platform-specific way
214 #![allow(unused_features)]
215 #![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count))]
216 #![cfg_attr(
217     all(target_vendor = "fortanix", target_env = "sgx"),
218     feature(slice_index_methods, coerce_unsized, sgx_platform)
219 )]
220 #![deny(rustc::existing_doc_keyword)]
221 //
222 // Language features:
223 #![feature(alloc_error_handler)]
224 #![feature(allocator_internals)]
225 #![feature(allow_internal_unsafe)]
226 #![feature(allow_internal_unstable)]
227 #![feature(box_syntax)]
228 #![feature(c_unwind)]
229 #![feature(cfg_target_thread_local)]
230 #![feature(concat_idents)]
231 #![feature(const_mut_refs)]
232 #![feature(const_trait_impl)]
233 #![feature(decl_macro)]
234 #![feature(deprecated_suggestion)]
235 #![feature(doc_cfg)]
236 #![feature(doc_cfg_hide)]
237 #![feature(doc_masked)]
238 #![feature(doc_notable_trait)]
239 #![feature(dropck_eyepatch)]
240 #![feature(exhaustive_patterns)]
241 #![feature(intra_doc_pointers)]
242 #![feature(label_break_value)]
243 #![feature(lang_items)]
244 #![feature(let_chains)]
245 #![feature(let_else)]
246 #![feature(linkage)]
247 #![feature(min_specialization)]
248 #![feature(must_not_suspend)]
249 #![feature(needs_panic_runtime)]
250 #![feature(negative_impls)]
251 #![feature(never_type)]
252 #![feature(platform_intrinsics)]
253 #![feature(prelude_import)]
254 #![feature(rustc_attrs)]
255 #![feature(rustdoc_internals)]
256 #![feature(staged_api)]
257 #![feature(thread_local)]
258 #![feature(try_blocks)]
259 //
260 // Library features (core):
261 #![feature(array_error_internals)]
262 #![feature(atomic_mut_ptr)]
263 #![feature(char_error_internals)]
264 #![feature(char_internals)]
265 #![feature(core_c_str)]
266 #![feature(core_intrinsics)]
267 #![feature(cstr_from_bytes_until_nul)]
268 #![feature(cstr_internals)]
269 #![feature(duration_checked_float)]
270 #![feature(duration_constants)]
271 #![feature(exact_size_is_empty)]
272 #![feature(extend_one)]
273 #![feature(float_minimum_maximum)]
274 #![feature(hasher_prefixfree_extras)]
275 #![feature(hashmap_internals)]
276 #![feature(int_error_internals)]
277 #![feature(maybe_uninit_slice)]
278 #![feature(maybe_uninit_write_slice)]
279 #![feature(mixed_integer_ops)]
280 #![feature(nonnull_slice_from_raw_parts)]
281 #![feature(panic_can_unwind)]
282 #![feature(panic_info_message)]
283 #![feature(panic_internals)]
284 #![feature(portable_simd)]
285 #![feature(prelude_2024)]
286 #![feature(ptr_as_uninit)]
287 #![feature(raw_os_nonzero)]
288 #![feature(slice_internals)]
289 #![feature(slice_ptr_get)]
290 #![feature(std_internals)]
291 #![feature(str_internals)]
292 #![feature(strict_provenance)]
293 //
294 // Library features (alloc):
295 #![feature(alloc_layout_extra)]
296 #![feature(alloc_c_string)]
297 #![feature(allocator_api)]
298 #![feature(get_mut_unchecked)]
299 #![feature(map_try_insert)]
300 #![feature(new_uninit)]
301 #![feature(thin_box)]
302 #![feature(try_reserve_kind)]
303 #![feature(vec_into_raw_parts)]
304 #![feature(slice_concat_trait)]
305 //
306 // Library features (unwind):
307 #![feature(panic_unwind)]
308 //
309 // Only for re-exporting:
310 #![feature(assert_matches)]
311 #![feature(async_iterator)]
312 #![feature(c_variadic)]
313 #![feature(cfg_accessible)]
314 #![feature(cfg_eval)]
315 #![feature(concat_bytes)]
316 #![feature(const_format_args)]
317 #![feature(core_ffi_c)]
318 #![feature(core_panic)]
319 #![feature(custom_test_frameworks)]
320 #![feature(edition_panic)]
321 #![feature(format_args_nl)]
322 #![feature(log_syntax)]
323 #![feature(once_cell)]
324 #![feature(saturating_int_impl)]
325 #![feature(stdsimd)]
326 #![feature(test)]
327 #![feature(trace_macros)]
328 //
329 // Only used in tests/benchmarks:
330 #![feature(bench_black_box)]
331 //
332 // Only for const-ness:
333 #![feature(const_io_structs)]
334 #![feature(const_ip)]
335 #![feature(const_ipv4)]
336 #![feature(const_ipv6)]
337 #![feature(const_socketaddr)]
338 #![feature(thread_local_internals)]
339 //
340 #![default_lib_allocator]
341
342 // Explicitly import the prelude. The compiler uses this same unstable attribute
343 // to import the prelude implicitly when building crates that depend on std.
344 #[prelude_import]
345 #[allow(unused)]
346 use prelude::rust_2021::*;
347
348 // Access to Bencher, etc.
349 #[cfg(test)]
350 extern crate test;
351
352 #[allow(unused_imports)] // macros from `alloc` are not used on all platforms
353 #[macro_use]
354 extern crate alloc as alloc_crate;
355 #[doc(masked)]
356 #[allow(unused_extern_crates)]
357 extern crate libc;
358
359 // We always need an unwinder currently for backtraces
360 #[doc(masked)]
361 #[allow(unused_extern_crates)]
362 extern crate unwind;
363
364 #[doc(masked)]
365 #[allow(unused_extern_crates)]
366 #[cfg(feature = "miniz_oxide")]
367 extern crate miniz_oxide;
368
369 // During testing, this crate is not actually the "real" std library, but rather
370 // it links to the real std library, which was compiled from this same source
371 // code. So any lang items std defines are conditionally excluded (or else they
372 // would generate duplicate lang item errors), and any globals it defines are
373 // _not_ the globals used by "real" std. So this import, defined only during
374 // testing gives test-std access to real-std lang items and globals. See #2912
375 #[cfg(test)]
376 extern crate std as realstd;
377
378 // The standard macros that are not built-in to the compiler.
379 #[macro_use]
380 mod macros;
381
382 // The runtime entry point and a few unstable public functions used by the
383 // compiler
384 #[macro_use]
385 pub mod rt;
386
387 // The Rust prelude
388 pub mod prelude;
389
390 // Public module declarations and re-exports
391 #[stable(feature = "rust1", since = "1.0.0")]
392 pub use alloc_crate::borrow;
393 #[stable(feature = "rust1", since = "1.0.0")]
394 pub use alloc_crate::boxed;
395 #[stable(feature = "rust1", since = "1.0.0")]
396 pub use alloc_crate::fmt;
397 #[stable(feature = "rust1", since = "1.0.0")]
398 pub use alloc_crate::format;
399 #[stable(feature = "rust1", since = "1.0.0")]
400 pub use alloc_crate::rc;
401 #[stable(feature = "rust1", since = "1.0.0")]
402 pub use alloc_crate::slice;
403 #[stable(feature = "rust1", since = "1.0.0")]
404 pub use alloc_crate::str;
405 #[stable(feature = "rust1", since = "1.0.0")]
406 pub use alloc_crate::string;
407 #[stable(feature = "rust1", since = "1.0.0")]
408 pub use alloc_crate::vec;
409 #[stable(feature = "rust1", since = "1.0.0")]
410 pub use core::any;
411 #[stable(feature = "core_array", since = "1.36.0")]
412 pub use core::array;
413 #[unstable(feature = "async_iterator", issue = "79024")]
414 pub use core::async_iter;
415 #[stable(feature = "rust1", since = "1.0.0")]
416 pub use core::cell;
417 #[stable(feature = "rust1", since = "1.0.0")]
418 pub use core::char;
419 #[stable(feature = "rust1", since = "1.0.0")]
420 pub use core::clone;
421 #[stable(feature = "rust1", since = "1.0.0")]
422 pub use core::cmp;
423 #[stable(feature = "rust1", since = "1.0.0")]
424 pub use core::convert;
425 #[stable(feature = "rust1", since = "1.0.0")]
426 pub use core::default;
427 #[stable(feature = "futures_api", since = "1.36.0")]
428 pub use core::future;
429 #[stable(feature = "rust1", since = "1.0.0")]
430 pub use core::hash;
431 #[stable(feature = "core_hint", since = "1.27.0")]
432 pub use core::hint;
433 #[stable(feature = "i128", since = "1.26.0")]
434 #[allow(deprecated, deprecated_in_future)]
435 pub use core::i128;
436 #[stable(feature = "rust1", since = "1.0.0")]
437 #[allow(deprecated, deprecated_in_future)]
438 pub use core::i16;
439 #[stable(feature = "rust1", since = "1.0.0")]
440 #[allow(deprecated, deprecated_in_future)]
441 pub use core::i32;
442 #[stable(feature = "rust1", since = "1.0.0")]
443 #[allow(deprecated, deprecated_in_future)]
444 pub use core::i64;
445 #[stable(feature = "rust1", since = "1.0.0")]
446 #[allow(deprecated, deprecated_in_future)]
447 pub use core::i8;
448 #[stable(feature = "rust1", since = "1.0.0")]
449 pub use core::intrinsics;
450 #[stable(feature = "rust1", since = "1.0.0")]
451 #[allow(deprecated, deprecated_in_future)]
452 pub use core::isize;
453 #[stable(feature = "rust1", since = "1.0.0")]
454 pub use core::iter;
455 #[stable(feature = "rust1", since = "1.0.0")]
456 pub use core::marker;
457 #[stable(feature = "rust1", since = "1.0.0")]
458 pub use core::mem;
459 #[stable(feature = "rust1", since = "1.0.0")]
460 pub use core::ops;
461 #[stable(feature = "rust1", since = "1.0.0")]
462 pub use core::option;
463 #[stable(feature = "pin", since = "1.33.0")]
464 pub use core::pin;
465 #[stable(feature = "rust1", since = "1.0.0")]
466 pub use core::ptr;
467 #[stable(feature = "rust1", since = "1.0.0")]
468 pub use core::result;
469 #[stable(feature = "i128", since = "1.26.0")]
470 #[allow(deprecated, deprecated_in_future)]
471 pub use core::u128;
472 #[stable(feature = "rust1", since = "1.0.0")]
473 #[allow(deprecated, deprecated_in_future)]
474 pub use core::u16;
475 #[stable(feature = "rust1", since = "1.0.0")]
476 #[allow(deprecated, deprecated_in_future)]
477 pub use core::u32;
478 #[stable(feature = "rust1", since = "1.0.0")]
479 #[allow(deprecated, deprecated_in_future)]
480 pub use core::u64;
481 #[stable(feature = "rust1", since = "1.0.0")]
482 #[allow(deprecated, deprecated_in_future)]
483 pub use core::u8;
484 #[stable(feature = "rust1", since = "1.0.0")]
485 #[allow(deprecated, deprecated_in_future)]
486 pub use core::usize;
487
488 pub mod f32;
489 pub mod f64;
490
491 #[macro_use]
492 pub mod thread;
493 pub mod ascii;
494 pub mod backtrace;
495 pub mod collections;
496 pub mod env;
497 pub mod error;
498 pub mod ffi;
499 pub mod fs;
500 pub mod io;
501 pub mod net;
502 pub mod num;
503 pub mod os;
504 pub mod panic;
505 pub mod path;
506 pub mod process;
507 pub mod sync;
508 pub mod time;
509
510 #[unstable(feature = "once_cell", issue = "74465")]
511 pub mod lazy;
512
513 // Pull in `std_float` crate  into libstd. The contents of
514 // `std_float` are in a different repository: rust-lang/portable-simd.
515 #[path = "../../portable-simd/crates/std_float/src/lib.rs"]
516 #[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
517 #[allow(rustdoc::bare_urls)]
518 #[unstable(feature = "portable_simd", issue = "86656")]
519 mod std_float;
520
521 #[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
522 #[unstable(feature = "portable_simd", issue = "86656")]
523 pub mod simd {
524     #[doc(inline)]
525     pub use crate::std_float::StdFloat;
526     #[doc(inline)]
527     pub use core::simd::*;
528 }
529
530 #[stable(feature = "futures_api", since = "1.36.0")]
531 pub mod task {
532     //! Types and Traits for working with asynchronous tasks.
533
534     #[doc(inline)]
535     #[stable(feature = "futures_api", since = "1.36.0")]
536     pub use core::task::*;
537
538     #[doc(inline)]
539     #[stable(feature = "wake_trait", since = "1.51.0")]
540     pub use alloc::task::*;
541 }
542
543 #[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
544 #[stable(feature = "simd_arch", since = "1.27.0")]
545 pub mod arch {
546     #[stable(feature = "simd_arch", since = "1.27.0")]
547     // The `no_inline`-attribute is required to make the documentation of all
548     // targets available.
549     // See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
550     // more information.
551     #[doc(no_inline)] // Note (#82861): required for correct documentation
552     pub use core::arch::*;
553
554     #[stable(feature = "simd_aarch64", since = "1.60.0")]
555     pub use std_detect::is_aarch64_feature_detected;
556     #[stable(feature = "simd_x86", since = "1.27.0")]
557     pub use std_detect::is_x86_feature_detected;
558     #[unstable(feature = "stdsimd", issue = "48556")]
559     pub use std_detect::{
560         is_arm_feature_detected, is_mips64_feature_detected, is_mips_feature_detected,
561         is_powerpc64_feature_detected, is_powerpc_feature_detected, is_riscv_feature_detected,
562     };
563 }
564
565 // This was stabilized in the crate root so we have to keep it there.
566 #[stable(feature = "simd_x86", since = "1.27.0")]
567 pub use std_detect::is_x86_feature_detected;
568
569 // Platform-abstraction modules
570 mod sys;
571 mod sys_common;
572
573 pub mod alloc;
574
575 // Private support modules
576 mod panicking;
577
578 #[path = "../../backtrace/src/lib.rs"]
579 #[allow(dead_code, unused_attributes)]
580 mod backtrace_rs;
581
582 // Re-export macros defined in libcore.
583 #[stable(feature = "rust1", since = "1.0.0")]
584 #[allow(deprecated, deprecated_in_future)]
585 pub use core::{
586     assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, r#try, todo,
587     unimplemented, unreachable, write, writeln,
588 };
589
590 // Re-export built-in macros defined through libcore.
591 #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
592 #[allow(deprecated)]
593 pub use core::{
594     assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
595     env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
596     module_path, option_env, stringify, trace_macros,
597 };
598
599 #[unstable(
600     feature = "concat_bytes",
601     issue = "87555",
602     reason = "`concat_bytes` is not stable enough for use and is subject to change"
603 )]
604 pub use core::concat_bytes;
605
606 #[stable(feature = "core_primitive", since = "1.43.0")]
607 pub use core::primitive;
608
609 // Include a number of private modules that exist solely to provide
610 // the rustdoc documentation for primitive types. Using `include!`
611 // because rustdoc only looks for these modules at the crate level.
612 include!("primitive_docs.rs");
613
614 // Include a number of private modules that exist solely to provide
615 // the rustdoc documentation for the existing keywords. Using `include!`
616 // because rustdoc only looks for these modules at the crate level.
617 include!("keyword_docs.rs");
618
619 // This is required to avoid an unstable error when `restricted-std` is not
620 // enabled. The use of #![feature(restricted_std)] in rustc-std-workspace-std
621 // is unconditional, so the unstable feature needs to be defined somewhere.
622 #[unstable(feature = "restricted_std", issue = "none")]
623 mod __restricted_std_workaround {}
624
625 mod sealed {
626     /// This trait being unreachable from outside the crate
627     /// prevents outside implementations of our extension traits.
628     /// This allows adding more trait methods in the future.
629     #[unstable(feature = "sealed", issue = "none")]
630     pub trait Sealed {}
631 }