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