]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Auto merge of #58316 - Centril:rollup, r=Centril
[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(fn_traits)]
14 #![feature(unsize)]
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(integer_atomics)]
23
24 #![cfg_attr(unix, feature(libc))]
25 #![cfg_attr(test, feature(test))]
26
27 #![deny(rust_2018_idioms)]
28
29 #[macro_use]
30 extern crate log;
31 #[allow(unused_extern_crates)]
32 extern crate serialize as rustc_serialize; // used by deriving
33 #[cfg(unix)]
34 extern crate libc;
35 #[macro_use]
36 extern crate cfg_if;
37
38 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
39 #[allow(unused_extern_crates)]
40 extern crate rustc_cratesio_shim;
41
42 pub use rustc_serialize::hex::ToHex;
43
44 #[macro_export]
45 macro_rules! likely {
46       ($e:expr) => {
47             #[allow(unused_unsafe)]
48             {
49                   unsafe { std::intrinsics::likely($e) }
50             }
51       }
52 }
53
54 #[macro_export]
55 macro_rules! unlikely {
56     ($e:expr) => {
57             #[allow(unused_unsafe)]
58             {
59                   unsafe { std::intrinsics::unlikely($e) }
60             }
61       }
62 }
63
64 pub mod macros;
65 pub mod svh;
66 pub mod base_n;
67 pub mod bit_set;
68 pub mod const_cstr;
69 pub mod flock;
70 pub mod fx;
71 pub mod graph;
72 pub mod indexed_vec;
73 pub mod interner;
74 pub mod obligation_forest;
75 pub mod owning_ref;
76 pub mod ptr_key;
77 pub mod sip128;
78 pub mod small_c_str;
79 pub mod snapshot_map;
80 pub use ena::snapshot_vec;
81 pub mod sorted_map;
82 #[macro_use] pub mod stable_hasher;
83 pub mod sync;
84 pub mod tiny_list;
85 pub mod thin_vec;
86 pub mod transitive_relation;
87 pub use ena::unify;
88 pub mod vec_linked_list;
89 pub mod work_queue;
90 pub mod fingerprint;
91
92 pub struct OnDrop<F: Fn()>(pub F);
93
94 impl<F: Fn()> OnDrop<F> {
95       /// Forgets the function which prevents it from running.
96       /// Ensure that the function owns no memory, otherwise it will be leaked.
97       #[inline]
98       pub fn disable(self) {
99             std::mem::forget(self);
100       }
101 }
102
103 impl<F: Fn()> Drop for OnDrop<F> {
104       #[inline]
105       fn drop(&mut self) {
106             (self.0)();
107       }
108 }
109
110 // See comments in src/librustc/lib.rs
111 #[doc(hidden)]
112 pub fn __noop_fix_for_27438() {}