| 1 | //! The first version of the prelude of The Rust Standard Library. |
| 2 | //! |
| 3 | //! See the [module-level documentation](super) for more. |
| 4 | |
| 5 | #![stable (feature = "rust1" , since = "1.0.0" )] |
| 6 | |
| 7 | // No formatting: this file is nothing but re-exports, and their order is worth preserving. |
| 8 | #![cfg_attr (rustfmt, rustfmt::skip)] |
| 9 | |
| 10 | // Re-exported core operators |
| 11 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 12 | #[doc (no_inline)] |
| 13 | pub use crate::marker::{Send, Sized, Sync, Unpin}; |
| 14 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 15 | #[doc (no_inline)] |
| 16 | pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; |
| 17 | #[stable (feature = "async_closure" , since = "1.85.0" )] |
| 18 | #[doc (no_inline)] |
| 19 | pub use crate::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; |
| 20 | |
| 21 | // Re-exported functions |
| 22 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 23 | #[doc (no_inline)] |
| 24 | pub use crate::mem::drop; |
| 25 | #[stable (feature = "size_of_prelude" , since = "1.80.0" )] |
| 26 | #[doc (no_inline)] |
| 27 | pub use crate::mem::{align_of, align_of_val, size_of, size_of_val}; |
| 28 | |
| 29 | // Re-exported types and traits |
| 30 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 31 | #[doc (no_inline)] |
| 32 | pub use crate::convert::{AsMut, AsRef, From, Into}; |
| 33 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 34 | #[doc (no_inline)] |
| 35 | pub use crate::iter::{DoubleEndedIterator, ExactSizeIterator}; |
| 36 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 37 | #[doc (no_inline)] |
| 38 | pub use crate::iter::{Extend, IntoIterator, Iterator}; |
| 39 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 40 | #[doc (no_inline)] |
| 41 | pub use crate::option::Option::{self, None, Some}; |
| 42 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 43 | #[doc (no_inline)] |
| 44 | pub use crate::result::Result::{self, Err, Ok}; |
| 45 | |
| 46 | // Re-exported built-in macros and traits |
| 47 | #[stable (feature = "builtin_macro_prelude" , since = "1.38.0" )] |
| 48 | #[doc (no_inline)] |
| 49 | #[expect (deprecated)] |
| 50 | pub use core::prelude::v1::{ |
| 51 | assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, |
| 52 | debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, |
| 53 | module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write, |
| 54 | writeln, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, |
| 55 | }; |
| 56 | |
| 57 | #[stable (feature = "builtin_macro_prelude" , since = "1.38.0" )] |
| 58 | #[doc (no_inline)] |
| 59 | pub use crate::{ |
| 60 | dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local |
| 61 | }; |
| 62 | |
| 63 | // These macros need special handling, so that we don't export them *and* the modules of the same |
| 64 | // name. We only want the macros in the prelude so we shadow the original modules with private |
| 65 | // modules with the same names. |
| 66 | mod ambiguous_macros_only { |
| 67 | #[expect (hidden_glob_reexports)] |
| 68 | mod vec {} |
| 69 | #[expect (hidden_glob_reexports)] |
| 70 | mod panic {} |
| 71 | // Building std without the expect exported_private_dependencies will create warnings, but then |
| 72 | // clippy claims its a useless_attribute. So silence both. |
| 73 | #[expect (clippy::useless_attribute)] |
| 74 | #[expect (exported_private_dependencies)] |
| 75 | #[stable (feature = "builtin_macro_prelude" , since = "1.38.0" )] |
| 76 | pub use crate::*; |
| 77 | } |
| 78 | #[stable (feature = "builtin_macro_prelude" , since = "1.38.0" )] |
| 79 | #[doc (no_inline)] |
| 80 | pub use self::ambiguous_macros_only::{vec, panic}; |
| 81 | |
| 82 | #[unstable (feature = "cfg_select" , issue = "115585" )] |
| 83 | #[doc (no_inline)] |
| 84 | pub use core::prelude::v1::cfg_select; |
| 85 | |
| 86 | #[unstable ( |
| 87 | feature = "concat_bytes" , |
| 88 | issue = "87555" , |
| 89 | reason = "`concat_bytes` is not stable enough for use and is subject to change" |
| 90 | )] |
| 91 | #[doc (no_inline)] |
| 92 | pub use core::prelude::v1::concat_bytes; |
| 93 | |
| 94 | #[unstable (feature = "const_format_args" , issue = "none" )] |
| 95 | #[doc (no_inline)] |
| 96 | pub use core::prelude::v1::const_format_args; |
| 97 | |
| 98 | #[unstable ( |
| 99 | feature = "log_syntax" , |
| 100 | issue = "29598" , |
| 101 | reason = "`log_syntax!` is not stable enough for use and is subject to change" |
| 102 | )] |
| 103 | #[doc (no_inline)] |
| 104 | pub use core::prelude::v1::log_syntax; |
| 105 | |
| 106 | #[unstable ( |
| 107 | feature = "trace_macros" , |
| 108 | issue = "29598" , |
| 109 | reason = "`trace_macros` is not stable enough for use and is subject to change" |
| 110 | )] |
| 111 | #[doc (no_inline)] |
| 112 | pub use core::prelude::v1::trace_macros; |
| 113 | |
| 114 | // Do not `doc(no_inline)` so that they become doc items on their own |
| 115 | // (no public module for them to be re-exported from). |
| 116 | #[stable (feature = "builtin_macro_prelude" , since = "1.38.0" )] |
| 117 | pub use core::prelude::v1::{ |
| 118 | alloc_error_handler, bench, derive, global_allocator, test, test_case, |
| 119 | }; |
| 120 | |
| 121 | #[unstable (feature = "derive_const" , issue = "118304" )] |
| 122 | pub use core::prelude::v1::derive_const; |
| 123 | |
| 124 | // Do not `doc(no_inline)` either. |
| 125 | #[unstable ( |
| 126 | feature = "cfg_accessible" , |
| 127 | issue = "64797" , |
| 128 | reason = "`cfg_accessible` is not fully implemented" |
| 129 | )] |
| 130 | pub use core::prelude::v1::cfg_accessible; |
| 131 | |
| 132 | // Do not `doc(no_inline)` either. |
| 133 | #[unstable ( |
| 134 | feature = "cfg_eval" , |
| 135 | issue = "82679" , |
| 136 | reason = "`cfg_eval` is a recently implemented feature" |
| 137 | )] |
| 138 | pub use core::prelude::v1::cfg_eval; |
| 139 | |
| 140 | // Do not `doc(no_inline)` either. |
| 141 | #[unstable ( |
| 142 | feature = "type_ascription" , |
| 143 | issue = "23416" , |
| 144 | reason = "placeholder syntax for type ascription" |
| 145 | )] |
| 146 | pub use core::prelude::v1::type_ascribe; |
| 147 | |
| 148 | // Do not `doc(no_inline)` either. |
| 149 | #[unstable ( |
| 150 | feature = "deref_patterns" , |
| 151 | issue = "87121" , |
| 152 | reason = "placeholder syntax for deref patterns" |
| 153 | )] |
| 154 | pub use core::prelude::v1::deref; |
| 155 | |
| 156 | // Do not `doc(no_inline)` either. |
| 157 | #[unstable ( |
| 158 | feature = "type_alias_impl_trait" , |
| 159 | issue = "63063" , |
| 160 | reason = "`type_alias_impl_trait` has open design concerns" |
| 161 | )] |
| 162 | pub use core::prelude::v1::define_opaque; |
| 163 | |
| 164 | #[unstable (feature = "extern_item_impls" , issue = "125418" )] |
| 165 | pub use core::prelude::v1::{eii, unsafe_eii}; |
| 166 | |
| 167 | #[unstable (feature = "eii_internals" , issue = "none" )] |
| 168 | pub use core::prelude::v1::eii_declaration; |
| 169 | |
| 170 | // The file so far is equivalent to core/src/prelude/v1.rs. It is duplicated |
| 171 | // rather than glob imported because we want docs to show these re-exports as |
| 172 | // pointing to within `std`. |
| 173 | // Below are the items from the alloc crate. |
| 174 | |
| 175 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 176 | #[doc (no_inline)] |
| 177 | pub use crate::borrow::ToOwned; |
| 178 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 179 | #[doc (no_inline)] |
| 180 | pub use crate::boxed::Box; |
| 181 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 182 | #[doc (no_inline)] |
| 183 | pub use crate::string::{String, ToString}; |
| 184 | #[stable (feature = "rust1" , since = "1.0.0" )] |
| 185 | #[doc (no_inline)] |
| 186 | pub use crate::vec::Vec; |
| 187 | |