]> git.lizzy.rs Git - rust.git/blob - src/libcore/lib.rs
Deny intra_doc_link_resolution_failure in libcore
[rust.git] / src / libcore / lib.rs
1 //! # The Rust Core Library
2 //!
3 //! The Rust Core Library is the dependency-free[^free] foundation of [The
4 //! Rust Standard Library](../std/index.html). It is the portable glue
5 //! between the language and its libraries, defining the intrinsic and
6 //! primitive building blocks of all Rust code. It links to no
7 //! upstream libraries, no system libraries, and no libc.
8 //!
9 //! [^free]: Strictly speaking, there are some symbols which are needed but
10 //!          they aren't always necessary.
11 //!
12 //! The core library is *minimal*: it isn't even aware of heap allocation,
13 //! nor does it provide concurrency or I/O. These things require
14 //! platform integration, and this library is platform-agnostic.
15 //!
16 //! # How to use the core library
17 //!
18 //! Please note that all of these details are currently not considered stable.
19 //!
20 // FIXME: Fill me in with more detail when the interface settles
21 //! This library is built on the assumption of a few existing symbols:
22 //!
23 //! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
24 //!   often generated by LLVM. Additionally, this library can make explicit
25 //!   calls to these functions. Their signatures are the same as found in C.
26 //!   These functions are often provided by the system libc, but can also be
27 //!   provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins).
28 //!
29 //! * `rust_begin_panic` - This function takes four arguments, a
30 //!   `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments
31 //!   dictate the panic message, the file at which panic was invoked, and the
32 //!   line and column inside the file. It is up to consumers of this core
33 //!   library to define this panic function; it is only required to never
34 //!   return. This requires a `lang` attribute named `panic_impl`.
35 //!
36 //! * `rust_eh_personality` - is used by the failure mechanisms of the
37 //!    compiler. This is often mapped to GCC's personality function, but crates
38 //!    which do not trigger a panic can be assured that this function is never
39 //!    called. The `lang` attribute is called `eh_personality`.
40
41 // Since libcore defines many fundamental lang items, all tests live in a
42 // separate crate, libcoretest, to avoid bizarre issues.
43 //
44 // Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
45 // this, both the generated test artifact and the linked libtest (which
46 // transitively includes libcore) will both define the same set of lang items,
47 // and this will cause the E0152 "found duplicate lang item" error. See
48 // discussion in #50466 for details.
49 //
50 // This cfg won't affect doc tests.
51 #![cfg(not(test))]
52 #![stable(feature = "core", since = "1.6.0")]
53 #![doc(
54     html_root_url = "https://doc.rust-lang.org/nightly/",
55     html_playground_url = "https://play.rust-lang.org/",
56     issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
57     test(no_crate_inject, attr(deny(warnings))),
58     test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
59 )]
60 #![no_core]
61 #![warn(deprecated_in_future)]
62 #![warn(missing_docs)]
63 #![warn(missing_debug_implementations)]
64 #![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
65 #![allow(explicit_outlives_requirements)]
66 #![allow(incomplete_features)]
67 #![feature(allow_internal_unstable)]
68 #![feature(arbitrary_self_types)]
69 #![feature(asm)]
70 #![feature(bound_cloned)]
71 #![feature(cfg_target_has_atomic)]
72 #![feature(concat_idents)]
73 #![feature(const_ascii_ctype_on_intrinsics)]
74 #![feature(const_alloc_layout)]
75 #![feature(const_discriminant)]
76 #![feature(const_checked_int_methods)]
77 #![feature(const_euclidean_int_methods)]
78 #![feature(const_overflowing_int_methods)]
79 #![feature(const_saturating_int_methods)]
80 #![feature(const_int_unchecked_arith)]
81 #![feature(const_int_pow)]
82 #![feature(constctlz)]
83 #![feature(const_panic)]
84 #![feature(const_fn_union)]
85 #![feature(const_generics)]
86 #![feature(const_ptr_offset)]
87 #![feature(const_ptr_offset_from)]
88 #![feature(const_raw_ptr_comparison)]
89 #![feature(const_result)]
90 #![feature(const_slice_from_raw_parts)]
91 #![feature(const_slice_ptr_len)]
92 #![feature(const_type_name)]
93 #![feature(const_likely)]
94 #![feature(custom_inner_attributes)]
95 #![feature(decl_macro)]
96 #![feature(doc_cfg)]
97 #![cfg_attr(not(bootstrap), feature(doc_spotlight))]
98 #![feature(duration_consts_2)]
99 #![feature(extern_types)]
100 #![feature(fundamental)]
101 #![feature(intrinsics)]
102 #![feature(try_find)]
103 #![feature(is_sorted)]
104 #![feature(lang_items)]
105 #![feature(link_llvm_intrinsics)]
106 #![feature(llvm_asm)]
107 #![feature(negative_impls)]
108 #![feature(never_type)]
109 #![feature(nll)]
110 #![feature(exhaustive_patterns)]
111 #![feature(no_core)]
112 #![feature(optin_builtin_traits)]
113 #![feature(or_patterns)]
114 #![feature(prelude_import)]
115 #![feature(repr_simd, platform_intrinsics)]
116 #![feature(rustc_attrs)]
117 #![feature(simd_ffi)]
118 #![feature(specialization)]
119 #![feature(staged_api)]
120 #![feature(std_internals)]
121 #![feature(stmt_expr_attributes)]
122 #![feature(transparent_unions)]
123 #![feature(unboxed_closures)]
124 #![feature(unsized_locals)]
125 #![feature(untagged_unions)]
126 #![feature(unwind_attributes)]
127 #![feature(variant_count)]
128 #![feature(doc_alias)]
129 #![feature(mmx_target_feature)]
130 #![feature(tbm_target_feature)]
131 #![feature(sse4a_target_feature)]
132 #![feature(arm_target_feature)]
133 #![feature(powerpc_target_feature)]
134 #![feature(mips_target_feature)]
135 #![feature(aarch64_target_feature)]
136 #![feature(wasm_target_feature)]
137 #![feature(avx512_target_feature)]
138 #![feature(cmpxchg16b_target_feature)]
139 #![feature(rtm_target_feature)]
140 #![feature(f16c_target_feature)]
141 #![feature(hexagon_target_feature)]
142 #![feature(const_fn_transmute)]
143 #![feature(abi_unadjusted)]
144 #![feature(adx_target_feature)]
145 #![feature(maybe_uninit_slice)]
146 #![feature(external_doc)]
147 #![feature(associated_type_bounds)]
148 #![feature(const_type_id)]
149 #![feature(const_caller_location)]
150 #![feature(slice_ptr_get)]
151 #![feature(no_niche)] // rust-lang/rust#68303
152 #![feature(unsafe_block_in_unsafe_fn)]
153 #![deny(intra_doc_link_resolution_failure)]
154 #![deny(unsafe_op_in_unsafe_fn)]
155
156 #[prelude_import]
157 #[allow(unused)]
158 use prelude::v1::*;
159
160 #[cfg(not(test))] // See #65860
161 #[macro_use]
162 mod macros;
163
164 #[macro_use]
165 mod internal_macros;
166
167 #[path = "num/int_macros.rs"]
168 #[macro_use]
169 mod int_macros;
170
171 #[path = "num/i128.rs"]
172 pub mod i128;
173 #[path = "num/i16.rs"]
174 pub mod i16;
175 #[path = "num/i32.rs"]
176 pub mod i32;
177 #[path = "num/i64.rs"]
178 pub mod i64;
179 #[path = "num/i8.rs"]
180 pub mod i8;
181 #[path = "num/isize.rs"]
182 pub mod isize;
183
184 #[path = "num/u128.rs"]
185 pub mod u128;
186 #[path = "num/u16.rs"]
187 pub mod u16;
188 #[path = "num/u32.rs"]
189 pub mod u32;
190 #[path = "num/u64.rs"]
191 pub mod u64;
192 #[path = "num/u8.rs"]
193 pub mod u8;
194 #[path = "num/usize.rs"]
195 pub mod usize;
196
197 #[path = "num/f32.rs"]
198 pub mod f32;
199 #[path = "num/f64.rs"]
200 pub mod f64;
201
202 #[macro_use]
203 pub mod num;
204
205 /* The libcore prelude, not as all-encompassing as the libstd prelude */
206
207 pub mod prelude;
208
209 /* Core modules for ownership management */
210
211 pub mod hint;
212 pub mod intrinsics;
213 pub mod mem;
214 pub mod ptr;
215
216 /* Core language traits */
217
218 pub mod borrow;
219 #[cfg(not(test))] // See #65860
220 pub mod clone;
221 #[cfg(not(test))] // See #65860
222 pub mod cmp;
223 pub mod convert;
224 #[cfg(not(test))] // See #65860
225 pub mod default;
226 #[cfg(not(test))] // See #65860
227 pub mod marker;
228 pub mod ops;
229
230 /* Core types and methods on primitives */
231
232 pub mod any;
233 #[cfg(not(test))] // See #65860
234 pub mod array;
235 pub mod ascii;
236 pub mod cell;
237 pub mod char;
238 pub mod ffi;
239 #[cfg(not(test))] // See #65860
240 pub mod iter;
241 pub mod option;
242 pub mod panic;
243 pub mod panicking;
244 #[cfg(not(test))] // See #65860
245 pub mod pin;
246 pub mod raw;
247 pub mod result;
248 pub mod sync;
249
250 #[cfg(not(test))] // See #65860
251 pub mod fmt;
252 #[cfg(not(test))] // See #65860
253 pub mod hash;
254 pub mod slice;
255 #[cfg(not(test))] // See #65860
256 pub mod str;
257 pub mod time;
258
259 pub mod unicode;
260
261 /* Async */
262 #[cfg(not(test))] // See #65860
263 pub mod future;
264 pub mod task;
265
266 /* Heap memory allocator trait */
267 #[allow(missing_docs)]
268 pub mod alloc;
269
270 // note: does not need to be public
271 mod bool;
272 mod tuple;
273 mod unit;
274
275 #[stable(feature = "core_primitive", since = "1.43.0")]
276 pub mod primitive;
277
278 // Pull in the `core_arch` crate directly into libcore. The contents of
279 // `core_arch` are in a different repository: rust-lang/stdarch.
280 //
281 // `core_arch` depends on libcore, but the contents of this module are
282 // set up in such a way that directly pulling it here works such that the
283 // crate uses the this crate as its libcore.
284 #[path = "../stdarch/crates/core_arch/src/mod.rs"]
285 #[allow(
286     missing_docs,
287     missing_debug_implementations,
288     dead_code,
289     unused_imports,
290     unsafe_op_in_unsafe_fn
291 )]
292 // FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
293 // merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
294 #[allow(clashing_extern_declarations)]
295 #[unstable(feature = "stdsimd", issue = "48556")]
296 mod core_arch;
297
298 #[stable(feature = "simd_arch", since = "1.27.0")]
299 pub use core_arch::arch;