]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_data_structures/src/lib.rs
Rollup merge of #91721 - danielhenrymantilla:patch-1, r=joshtriplett
[rust.git] / compiler / rustc_data_structures / src / lib.rs
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
9 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
10 #![feature(array_windows)]
11 #![feature(associated_type_bounds)]
12 #![feature(auto_traits)]
13 #![feature(bool_to_option)]
14 #![feature(control_flow_enum)]
15 #![feature(core_intrinsics)]
16 #![feature(extend_one)]
17 #![feature(hash_raw_entry)]
18 #![feature(maybe_uninit_uninit_array)]
19 #![feature(min_specialization)]
20 #![feature(never_type)]
21 #![feature(type_alias_impl_trait)]
22 #![feature(new_uninit)]
23 #![feature(once_cell)]
24 #![feature(test)]
25 #![feature(thread_id_value)]
26 #![feature(vec_into_raw_parts)]
27 #![allow(rustc::default_hash_types)]
28 #![deny(unaligned_references)]
29
30 #[macro_use]
31 extern crate tracing;
32 #[macro_use]
33 extern crate cfg_if;
34 #[macro_use]
35 extern crate rustc_macros;
36
37 #[inline(never)]
38 #[cold]
39 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
40     f()
41 }
42
43 #[macro_export]
44 macro_rules! likely {
45     ($e:expr) => {
46         match $e {
47             #[allow(unused_unsafe)]
48             e => unsafe { std::intrinsics::likely(e) },
49         }
50     };
51 }
52
53 #[macro_export]
54 macro_rules! unlikely {
55     ($e:expr) => {
56         match $e {
57             #[allow(unused_unsafe)]
58             e => unsafe { std::intrinsics::unlikely(e) },
59         }
60     };
61 }
62
63 pub mod base_n;
64 pub mod binary_search_util;
65 pub mod captures;
66 pub mod flock;
67 pub mod functor;
68 pub mod fx;
69 pub mod graph;
70 pub mod jobserver;
71 pub mod macros;
72 pub mod map_in_place;
73 pub mod obligation_forest;
74 pub mod owning_ref;
75 pub mod ptr_key;
76 pub mod sip128;
77 pub mod small_c_str;
78 pub mod snapshot_map;
79 pub mod stable_map;
80 pub mod svh;
81 pub use ena::snapshot_vec;
82 pub mod memmap;
83 pub mod sorted_map;
84 pub mod stable_set;
85 #[macro_use]
86 pub mod stable_hasher;
87 mod atomic_ref;
88 pub mod fingerprint;
89 pub mod profiling;
90 pub mod sharded;
91 pub mod stack;
92 pub mod sync;
93 pub mod thin_vec;
94 pub mod tiny_list;
95 pub mod transitive_relation;
96 pub mod vec_linked_list;
97 pub mod vec_map;
98 pub mod work_queue;
99 pub use atomic_ref::AtomicRef;
100 pub mod frozen;
101 pub mod sso;
102 pub mod steal;
103 pub mod tagged_ptr;
104 pub mod temp_dir;
105 pub mod unhash;
106
107 pub use ena::undo_log;
108 pub use ena::unify;
109
110 pub struct OnDrop<F: Fn()>(pub F);
111
112 impl<F: Fn()> OnDrop<F> {
113     /// Forgets the function which prevents it from running.
114     /// Ensure that the function owns no memory, otherwise it will be leaked.
115     #[inline]
116     pub fn disable(self) {
117         std::mem::forget(self);
118     }
119 }
120
121 impl<F: Fn()> Drop for OnDrop<F> {
122     #[inline]
123     fn drop(&mut self) {
124         (self.0)();
125     }
126 }
127
128 // See comments in src/librustc_middle/lib.rs
129 #[doc(hidden)]
130 pub fn __noop_fix_for_27438() {}