]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
perf: Reduce snapshot/rollback overhead
[rust.git] / src / librustc_data_structures / 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/")]
10 #![feature(in_band_lifetimes)]
11 #![feature(unboxed_closures)]
12 #![feature(generators)]
13 #![feature(generator_trait)]
14 #![feature(fn_traits)]
15 #![feature(specialization)]
16 #![feature(optin_builtin_traits)]
17 #![feature(nll)]
18 #![feature(allow_internal_unstable)]
19 #![feature(hash_raw_entry)]
20 #![feature(stmt_expr_attributes)]
21 #![feature(core_intrinsics)]
22 #![feature(test)]
23 #![feature(associated_type_bounds)]
24 #![feature(thread_id_value)]
25 #![allow(rustc::default_hash_types)]
26
27 #[macro_use]
28 extern crate log;
29 #[macro_use]
30 extern crate cfg_if;
31
32 #[inline(never)]
33 #[cold]
34 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
35     f()
36 }
37
38 #[macro_export]
39 macro_rules! likely {
40     ($e:expr) => {
41         #[allow(unused_unsafe)]
42         {
43             unsafe { std::intrinsics::likely($e) }
44         }
45     };
46 }
47
48 #[macro_export]
49 macro_rules! unlikely {
50     ($e:expr) => {
51         #[allow(unused_unsafe)]
52         {
53             unsafe { std::intrinsics::unlikely($e) }
54         }
55     };
56 }
57
58 pub mod base_n;
59 pub mod binary_search_util;
60 pub mod box_region;
61 pub mod captures;
62 pub mod const_cstr;
63 pub mod flock;
64 pub mod fx;
65 pub mod graph;
66 pub mod jobserver;
67 pub mod macros;
68 pub mod map_in_place;
69 pub mod obligation_forest;
70 pub mod owning_ref;
71 pub mod ptr_key;
72 pub mod sip128;
73 pub mod small_c_str;
74 pub mod snapshot_map;
75 pub mod stable_map;
76 pub mod svh;
77 pub use ena::snapshot_vec;
78 pub mod sorted_map;
79 pub mod stable_set;
80 #[macro_use]
81 pub mod stable_hasher;
82 pub mod sharded;
83 pub mod sync;
84 pub mod thin_vec;
85 pub mod tiny_list;
86 pub mod transitive_relation;
87 pub use ena::undo_log;
88 pub use ena::unify;
89 mod atomic_ref;
90 pub mod fingerprint;
91 pub mod profiling;
92 pub mod vec_linked_list;
93 pub mod work_queue;
94 pub use atomic_ref::AtomicRef;
95 pub mod frozen;
96
97 pub struct OnDrop<F: Fn()>(pub F);
98
99 impl<F: Fn()> OnDrop<F> {
100     /// Forgets the function which prevents it from running.
101     /// Ensure that the function owns no memory, otherwise it will be leaked.
102     #[inline]
103     pub fn disable(self) {
104         std::mem::forget(self);
105     }
106 }
107
108 impl<F: Fn()> Drop for OnDrop<F> {
109     #[inline]
110     fn drop(&mut self) {
111         (self.0)();
112     }
113 }
114
115 // See comments in src/librustc_middle/lib.rs
116 #[doc(hidden)]
117 pub fn __noop_fix_for_27438() {}