]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Rollup merge of #64852 - Baranowski:param_note_52082, r=estebank
[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 #![feature(test)]
26 #![feature(associated_type_bounds)]
27
28 #![cfg_attr(unix, feature(libc))]
29
30 #![allow(rustc::default_hash_types)]
31
32 #[macro_use]
33 extern crate log;
34 #[cfg(unix)]
35 extern crate libc;
36 #[macro_use]
37 extern crate cfg_if;
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 macros;
68 pub mod svh;
69 pub mod base_n;
70 pub mod binary_search_util;
71 pub mod bit_set;
72 pub mod box_region;
73 pub mod const_cstr;
74 pub mod flock;
75 pub mod fx;
76 pub mod stable_map;
77 pub mod graph;
78 pub mod indexed_vec;
79 pub mod jobserver;
80 pub mod obligation_forest;
81 pub mod owning_ref;
82 pub mod ptr_key;
83 pub mod sip128;
84 pub mod small_c_str;
85 pub mod snapshot_map;
86 pub use ena::snapshot_vec;
87 pub mod sorted_map;
88 pub mod stable_set;
89 #[macro_use] pub mod stable_hasher;
90 pub mod sync;
91 pub mod sharded;
92 pub mod tiny_list;
93 pub mod thin_vec;
94 pub mod transitive_relation;
95 pub use ena::unify;
96 pub mod vec_linked_list;
97 pub mod work_queue;
98 pub mod fingerprint;
99
100 pub struct OnDrop<F: Fn()>(pub F);
101
102 impl<F: Fn()> OnDrop<F> {
103       /// Forgets the function which prevents it from running.
104       /// Ensure that the function owns no memory, otherwise it will be leaked.
105       #[inline]
106       pub fn disable(self) {
107             std::mem::forget(self);
108       }
109 }
110
111 impl<F: Fn()> Drop for OnDrop<F> {
112       #[inline]
113       fn drop(&mut self) {
114             (self.0)();
115       }
116 }
117
118 // See comments in src/librustc/lib.rs
119 #[doc(hidden)]
120 pub fn __noop_fix_for_27438() {}