]>
Commit | Line | Data |
---|---|---|
d9579d0f | 1 | //! Various data structures used by the Rust compiler. The intention |
353b0b11 | 2 | //! is that code in here should not be *specific* to rustc, so that |
d9579d0f AL |
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)] | |
064997fb | 13 | #![feature(cell_leak)] |
9ffffee4 | 14 | #![feature(core_intrinsics)] |
136023e0 XL |
15 | #![feature(extend_one)] |
16 | #![feature(hash_raw_entry)] | |
04454e1e | 17 | #![feature(hasher_prefixfree_extras)] |
136023e0 | 18 | #![feature(maybe_uninit_uninit_array)] |
f9f354fc | 19 | #![feature(min_specialization)] |
c295e0f8 XL |
20 | #![feature(never_type)] |
21 | #![feature(type_alias_impl_trait)] | |
136023e0 | 22 | #![feature(new_uninit)] |
353b0b11 | 23 | #![feature(lazy_cell)] |
5099ac24 | 24 | #![feature(rustc_attrs)] |
2b03887a | 25 | #![feature(negative_impls)] |
416331ca | 26 | #![feature(test)] |
dfeec247 | 27 | #![feature(thread_id_value)] |
a2a8927a | 28 | #![feature(vec_into_raw_parts)] |
49aad941 | 29 | #![feature(allocator_api)] |
9ffffee4 | 30 | #![feature(get_mut_unchecked)] |
353b0b11 FG |
31 | #![feature(lint_reasons)] |
32 | #![feature(unwrap_infallible)] | |
49aad941 FG |
33 | #![feature(strict_provenance)] |
34 | #![feature(ptr_alignment_type)] | |
35 | #![feature(macro_metavar_expr)] | |
e1599b0c | 36 | #![allow(rustc::default_hash_types)] |
5e7ed085 | 37 | #![allow(rustc::potential_query_instability)] |
f2b60f7d FG |
38 | #![deny(rustc::untranslatable_diagnostic)] |
39 | #![deny(rustc::diagnostic_outside_of_impl)] | |
49aad941 | 40 | #![deny(unsafe_op_in_unsafe_fn)] |
9fa01778 | 41 | |
54a0048b | 42 | #[macro_use] |
3dfed10e | 43 | extern crate tracing; |
ff7c6d11 XL |
44 | #[macro_use] |
45 | extern crate cfg_if; | |
3dfed10e XL |
46 | #[macro_use] |
47 | extern crate rustc_macros; | |
d9579d0f | 48 | |
5e7ed085 FG |
49 | pub use rustc_index::static_assert_size; |
50 | ||
9fa01778 XL |
51 | #[inline(never)] |
52 | #[cold] | |
53 | pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R { | |
dfeec247 | 54 | f() |
9fa01778 XL |
55 | } |
56 | ||
476ff2be | 57 | pub mod base_n; |
dc9dc135 | 58 | pub mod binary_search_util; |
dfeec247 | 59 | pub mod captures; |
353b0b11 | 60 | pub mod flat_map_in_place; |
8faf50e0 | 61 | pub mod flock; |
fc512014 | 62 | pub mod functor; |
8faf50e0 | 63 | pub mod fx; |
e9174d1e | 64 | pub mod graph; |
5099ac24 | 65 | pub mod intern; |
532ac7d7 | 66 | pub mod jobserver; |
dfeec247 | 67 | pub mod macros; |
7453a54e | 68 | pub mod obligation_forest; |
abe05a73 | 69 | pub mod sip128; |
b7449926 | 70 | pub mod small_c_str; |
5e7ed085 | 71 | pub mod small_str; |
3157f602 | 72 | pub mod snapshot_map; |
dfeec247 | 73 | pub mod svh; |
0531ce1d | 74 | pub use ena::snapshot_vec; |
cdc7bbd5 | 75 | pub mod memmap; |
8faf50e0 | 76 | pub mod sorted_map; |
dfeec247 XL |
77 | #[macro_use] |
78 | pub mod stable_hasher; | |
6c58768f XL |
79 | mod atomic_ref; |
80 | pub mod fingerprint; | |
49aad941 | 81 | pub mod marker; |
6c58768f | 82 | pub mod profiling; |
416331ca | 83 | pub mod sharded; |
f9f354fc | 84 | pub mod stack; |
dfeec247 | 85 | pub mod sync; |
dfeec247 | 86 | pub mod tiny_list; |
8faf50e0 | 87 | pub mod transitive_relation; |
dfeec247 XL |
88 | pub mod vec_linked_list; |
89 | pub mod work_queue; | |
90 | pub use atomic_ref::AtomicRef; | |
49aad941 | 91 | pub mod aligned; |
ba9703b0 | 92 | pub mod frozen; |
49aad941 | 93 | mod hashes; |
353b0b11 | 94 | pub mod owned_slice; |
29967ef6 | 95 | pub mod sso; |
fc512014 | 96 | pub mod steal; |
3dfed10e XL |
97 | pub mod tagged_ptr; |
98 | pub mod temp_dir; | |
1b1a35ee | 99 | pub mod unhash; |
2b03887a | 100 | pub mod unord; |
e9174d1e | 101 | |
6c58768f XL |
102 | pub use ena::undo_log; |
103 | pub use ena::unify; | |
104 | ||
49aad941 FG |
105 | /// Returns a structure that calls `f` when dropped. |
106 | pub fn defer<F: FnOnce()>(f: F) -> OnDrop<F> { | |
107 | OnDrop(Some(f)) | |
108 | } | |
109 | ||
110 | pub struct OnDrop<F: FnOnce()>(Option<F>); | |
0531ce1d | 111 | |
49aad941 FG |
112 | impl<F: FnOnce()> OnDrop<F> { |
113 | /// Disables on-drop call. | |
dfeec247 | 114 | #[inline] |
49aad941 FG |
115 | pub fn disable(mut self) { |
116 | self.0.take(); | |
dfeec247 | 117 | } |
94b46f34 XL |
118 | } |
119 | ||
49aad941 | 120 | impl<F: FnOnce()> Drop for OnDrop<F> { |
dfeec247 XL |
121 | #[inline] |
122 | fn drop(&mut self) { | |
49aad941 FG |
123 | if let Some(f) = self.0.take() { |
124 | f(); | |
125 | } | |
dfeec247 | 126 | } |
0531ce1d XL |
127 | } |
128 | ||
ba9703b0 | 129 | // See comments in src/librustc_middle/lib.rs |
e9174d1e SL |
130 | #[doc(hidden)] |
131 | pub fn __noop_fix_for_27438() {} |