]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Rollup merge of #63055 - Mark-Simulacrum:save-analysis-clean-2, r=Xanewok
[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
11 #![feature(in_band_lifetimes)]
12 #![feature(unboxed_closures)]
13 #![feature(generators)]
14 #![feature(generator_trait)]
15 #![feature(fn_traits)]
16 #![feature(unsize)]
17 #![feature(specialization)]
18 #![feature(optin_builtin_traits)]
19 #![feature(nll)]
20 #![feature(allow_internal_unstable)]
21 #![feature(hash_raw_entry)]
22 #![feature(stmt_expr_attributes)]
23 #![feature(core_intrinsics)]
24 #![feature(integer_atomics)]
25
26 #![cfg_attr(unix, feature(libc))]
27 #![cfg_attr(test, feature(test))]
28
29 #![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
30
31 #[macro_use]
32 extern crate log;
33 #[cfg(unix)]
34 extern crate libc;
35 #[macro_use]
36 extern crate cfg_if;
37
38 pub use rustc_serialize::hex::ToHex;
39
40 #[inline(never)]
41 #[cold]
42 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
43       f()
44 }
45
46 #[macro_export]
47 macro_rules! likely {
48       ($e:expr) => {
49             #[allow(unused_unsafe)]
50             {
51                   unsafe { std::intrinsics::likely($e) }
52             }
53       }
54 }
55
56 #[macro_export]
57 macro_rules! unlikely {
58     ($e:expr) => {
59             #[allow(unused_unsafe)]
60             {
61                   unsafe { std::intrinsics::unlikely($e) }
62             }
63       }
64 }
65
66 pub mod macros;
67 pub mod svh;
68 pub mod base_n;
69 pub mod binary_search_util;
70 pub mod bit_set;
71 pub mod box_region;
72 pub mod const_cstr;
73 pub mod flock;
74 pub mod fx;
75 pub mod graph;
76 pub mod indexed_vec;
77 pub mod jobserver;
78 pub mod obligation_forest;
79 pub mod owning_ref;
80 pub mod ptr_key;
81 pub mod sip128;
82 pub mod small_c_str;
83 pub mod snapshot_map;
84 pub use ena::snapshot_vec;
85 pub mod sorted_map;
86 #[macro_use] pub mod stable_hasher;
87 pub mod sync;
88 pub mod sharded;
89 pub mod tiny_list;
90 pub mod thin_vec;
91 pub mod transitive_relation;
92 pub use ena::unify;
93 pub mod vec_linked_list;
94 pub mod work_queue;
95 pub mod fingerprint;
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/lib.rs
116 #[doc(hidden)]
117 pub fn __noop_fix_for_27438() {}