]>
Commit | Line | Data |
---|---|---|
d9579d0f AL |
1 | //! Various data structures used by the Rust compiler. The intention |
2 | //! is that code in here should be not be *specific* to rustc, so that | |
3 | //! it can be easily unit tested and so forth. | |
4 | //! | |
5 | //! # Note | |
6 | //! | |
7 | //! This API is completely unstable and subject to change. | |
8 | ||
1b1a35ee XL |
9 | #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] |
10 | #![feature(array_windows)] | |
136023e0 XL |
11 | #![feature(associated_type_bounds)] |
12 | #![feature(auto_traits)] | |
13 | #![feature(bool_to_option)] | |
1b1a35ee | 14 | #![feature(control_flow_enum)] |
136023e0 XL |
15 | #![feature(core_intrinsics)] |
16 | #![feature(extend_one)] | |
5e7ed085 | 17 | #![feature(let_else)] |
136023e0 | 18 | #![feature(hash_raw_entry)] |
136023e0 | 19 | #![feature(maybe_uninit_uninit_array)] |
f9f354fc | 20 | #![feature(min_specialization)] |
c295e0f8 XL |
21 | #![feature(never_type)] |
22 | #![feature(type_alias_impl_trait)] | |
136023e0 | 23 | #![feature(new_uninit)] |
136023e0 | 24 | #![feature(once_cell)] |
5099ac24 | 25 | #![feature(rustc_attrs)] |
416331ca | 26 | #![feature(test)] |
dfeec247 | 27 | #![feature(thread_id_value)] |
a2a8927a | 28 | #![feature(vec_into_raw_parts)] |
e1599b0c | 29 | #![allow(rustc::default_hash_types)] |
fc512014 | 30 | #![deny(unaligned_references)] |
5e7ed085 | 31 | #![allow(rustc::potential_query_instability)] |
9fa01778 | 32 | |
54a0048b | 33 | #[macro_use] |
3dfed10e | 34 | extern crate tracing; |
ff7c6d11 XL |
35 | #[macro_use] |
36 | extern crate cfg_if; | |
3dfed10e XL |
37 | #[macro_use] |
38 | extern crate rustc_macros; | |
d9579d0f | 39 | |
5e7ed085 FG |
40 | pub use rustc_index::static_assert_size; |
41 | ||
9fa01778 XL |
42 | #[inline(never)] |
43 | #[cold] | |
44 | pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R { | |
dfeec247 | 45 | f() |
9fa01778 XL |
46 | } |
47 | ||
0731742a XL |
48 | #[macro_export] |
49 | macro_rules! likely { | |
dfeec247 | 50 | ($e:expr) => { |
fc512014 XL |
51 | match $e { |
52 | #[allow(unused_unsafe)] | |
53 | e => unsafe { std::intrinsics::likely(e) }, | |
dfeec247 XL |
54 | } |
55 | }; | |
0731742a XL |
56 | } |
57 | ||
58 | #[macro_export] | |
59 | macro_rules! unlikely { | |
60 | ($e:expr) => { | |
fc512014 XL |
61 | match $e { |
62 | #[allow(unused_unsafe)] | |
63 | e => unsafe { std::intrinsics::unlikely(e) }, | |
dfeec247 XL |
64 | } |
65 | }; | |
0731742a XL |
66 | } |
67 | ||
476ff2be | 68 | pub mod base_n; |
dc9dc135 | 69 | pub mod binary_search_util; |
dfeec247 | 70 | pub mod captures; |
8faf50e0 | 71 | pub mod flock; |
fc512014 | 72 | pub mod functor; |
8faf50e0 | 73 | pub mod fx; |
e9174d1e | 74 | pub mod graph; |
5099ac24 | 75 | pub mod intern; |
532ac7d7 | 76 | pub mod jobserver; |
dfeec247 | 77 | pub mod macros; |
ba9703b0 | 78 | pub mod map_in_place; |
7453a54e | 79 | pub mod obligation_forest; |
8faf50e0 | 80 | pub mod owning_ref; |
abe05a73 | 81 | pub mod sip128; |
b7449926 | 82 | pub mod small_c_str; |
5e7ed085 | 83 | pub mod small_str; |
3157f602 | 84 | pub mod snapshot_map; |
dfeec247 XL |
85 | pub mod stable_map; |
86 | pub mod svh; | |
0531ce1d | 87 | pub use ena::snapshot_vec; |
cdc7bbd5 | 88 | pub mod memmap; |
8faf50e0 | 89 | pub mod sorted_map; |
e74abb32 | 90 | pub mod stable_set; |
dfeec247 XL |
91 | #[macro_use] |
92 | pub mod stable_hasher; | |
6c58768f XL |
93 | mod atomic_ref; |
94 | pub mod fingerprint; | |
95 | pub mod profiling; | |
416331ca | 96 | pub mod sharded; |
f9f354fc | 97 | pub mod stack; |
dfeec247 | 98 | pub mod sync; |
b7449926 | 99 | pub mod thin_vec; |
dfeec247 | 100 | pub mod tiny_list; |
8faf50e0 | 101 | pub mod transitive_relation; |
dfeec247 | 102 | pub mod vec_linked_list; |
17df50a5 | 103 | pub mod vec_map; |
dfeec247 XL |
104 | pub mod work_queue; |
105 | pub use atomic_ref::AtomicRef; | |
ba9703b0 | 106 | pub mod frozen; |
29967ef6 | 107 | pub mod sso; |
fc512014 | 108 | pub mod steal; |
3dfed10e XL |
109 | pub mod tagged_ptr; |
110 | pub mod temp_dir; | |
1b1a35ee | 111 | pub mod unhash; |
e9174d1e | 112 | |
6c58768f XL |
113 | pub use ena::undo_log; |
114 | pub use ena::unify; | |
115 | ||
0531ce1d XL |
116 | pub struct OnDrop<F: Fn()>(pub F); |
117 | ||
94b46f34 | 118 | impl<F: Fn()> OnDrop<F> { |
dfeec247 XL |
119 | /// Forgets the function which prevents it from running. |
120 | /// Ensure that the function owns no memory, otherwise it will be leaked. | |
121 | #[inline] | |
122 | pub fn disable(self) { | |
123 | std::mem::forget(self); | |
124 | } | |
94b46f34 XL |
125 | } |
126 | ||
0531ce1d | 127 | impl<F: Fn()> Drop for OnDrop<F> { |
dfeec247 XL |
128 | #[inline] |
129 | fn drop(&mut self) { | |
130 | (self.0)(); | |
131 | } | |
0531ce1d XL |
132 | } |
133 | ||
ba9703b0 | 134 | // See comments in src/librustc_middle/lib.rs |
e9174d1e SL |
135 | #[doc(hidden)] |
136 | pub fn __noop_fix_for_27438() {} |