]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Rollup merge of #67630 - oli-obk:extern_ptr_dangling, r=spastorino
[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 const_cstr;
71 pub mod flock;
72 pub mod fx;
73 pub mod graph;
74 pub mod jobserver;
75 pub mod macros;
76 pub mod obligation_forest;
77 pub mod owning_ref;
78 pub mod ptr_key;
79 pub mod sip128;
80 pub mod small_c_str;
81 pub mod snapshot_map;
82 pub mod stable_map;
83 pub mod svh;
84 pub use ena::snapshot_vec;
85 pub mod sorted_map;
86 pub mod stable_set;
87 #[macro_use]
88 pub mod stable_hasher;
89 pub mod sharded;
90 pub mod sync;
91 pub mod thin_vec;
92 pub mod tiny_list;
93 pub mod transitive_relation;
94 pub use ena::unify;
95 mod atomic_ref;
96 pub mod fingerprint;
97 pub mod profiling;
98 pub mod vec_linked_list;
99 pub mod work_queue;
100 pub use atomic_ref::AtomicRef;
101
102 pub struct OnDrop<F: Fn()>(pub F);
103
104 impl<F: Fn()> OnDrop<F> {
105     /// Forgets the function which prevents it from running.
106     /// Ensure that the function owns no memory, otherwise it will be leaked.
107     #[inline]
108     pub fn disable(self) {
109         std::mem::forget(self);
110     }
111 }
112
113 impl<F: Fn()> Drop for OnDrop<F> {
114     #[inline]
115     fn drop(&mut self) {
116         (self.0)();
117     }
118 }
119
120 // See comments in src/librustc/lib.rs
121 #[doc(hidden)]
122 pub fn __noop_fix_for_27438() {}