]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Auto merge of #67689 - mark-i-m:update-guide, r=JohnTitor
[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 const_cstr;
68 pub mod flock;
69 pub mod fx;
70 pub mod graph;
71 pub mod jobserver;
72 pub mod macros;
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 sorted_map;
83 pub mod stable_set;
84 #[macro_use]
85 pub mod stable_hasher;
86 pub mod sharded;
87 pub mod sync;
88 pub mod thin_vec;
89 pub mod tiny_list;
90 pub mod transitive_relation;
91 pub use ena::unify;
92 mod atomic_ref;
93 pub mod fingerprint;
94 pub mod profiling;
95 pub mod vec_linked_list;
96 pub mod work_queue;
97 pub use atomic_ref::AtomicRef;
98
99 pub struct OnDrop<F: Fn()>(pub F);
100
101 impl<F: Fn()> OnDrop<F> {
102     /// Forgets the function which prevents it from running.
103     /// Ensure that the function owns no memory, otherwise it will be leaked.
104     #[inline]
105     pub fn disable(self) {
106         std::mem::forget(self);
107     }
108 }
109
110 impl<F: Fn()> Drop for OnDrop<F> {
111     #[inline]
112     fn drop(&mut self) {
113         (self.0)();
114     }
115 }
116
117 // See comments in src/librustc/lib.rs
118 #[doc(hidden)]
119 pub fn __noop_fix_for_27438() {}