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