]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Rollup merge of #57667 - ishitatsuyuki:p-leak, r=nnethercote
[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_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
10       html_favicon_url = "https://www.rust-lang.org/favicon.ico",
11       html_root_url = "https://doc.rust-lang.org/nightly/")]
12
13 #![feature(in_band_lifetimes)]
14 #![feature(unboxed_closures)]
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
26 #![cfg_attr(unix, feature(libc))]
27 #![cfg_attr(test, feature(test))]
28
29 extern crate core;
30 extern crate ena;
31 #[macro_use]
32 extern crate log;
33 extern crate serialize as rustc_serialize; // used by deriving
34 #[cfg(unix)]
35 extern crate libc;
36 extern crate parking_lot;
37 #[macro_use]
38 extern crate cfg_if;
39 extern crate stable_deref_trait;
40 extern crate rustc_rayon as rayon;
41 extern crate rustc_rayon_core as rayon_core;
42 extern crate rustc_hash;
43 extern crate serialize;
44 extern crate graphviz;
45 extern crate smallvec;
46
47 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
48 #[allow(unused_extern_crates)]
49 extern crate rustc_cratesio_shim;
50
51 pub use rustc_serialize::hex::ToHex;
52
53 #[macro_export]
54 macro_rules! likely {
55       ($e:expr) => {
56             #[allow(unused_unsafe)]
57             {
58                   unsafe { std::intrinsics::likely($e) }
59             }
60       }
61 }
62
63 #[macro_export]
64 macro_rules! unlikely {
65     ($e:expr) => {
66             #[allow(unused_unsafe)]
67             {
68                   unsafe { std::intrinsics::unlikely($e) }
69             }
70       }
71 }
72
73 pub mod macros;
74 pub mod svh;
75 pub mod base_n;
76 pub mod bit_set;
77 pub mod const_cstr;
78 pub mod flock;
79 pub mod fx;
80 pub mod graph;
81 pub mod indexed_vec;
82 pub mod interner;
83 pub mod obligation_forest;
84 pub mod owning_ref;
85 pub mod ptr_key;
86 pub mod sip128;
87 pub mod small_c_str;
88 pub mod snapshot_map;
89 pub use ena::snapshot_vec;
90 pub mod sorted_map;
91 #[macro_use] pub mod stable_hasher;
92 pub mod sync;
93 pub mod tiny_list;
94 pub mod thin_vec;
95 pub mod transitive_relation;
96 pub use ena::unify;
97 pub mod vec_linked_list;
98 pub mod work_queue;
99 pub mod fingerprint;
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() {}