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