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