]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Rollup merge of #60187 - tmandry:generator-optimization, r=eddyb
[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
26 #![cfg_attr(unix, feature(libc))]
27 #![cfg_attr(test, feature(test))]
28
29 #![deny(rust_2018_idioms)]
30
31 #[macro_use]
32 extern crate log;
33 #[allow(unused_extern_crates)]
34 extern crate serialize as rustc_serialize; // used by deriving
35 #[cfg(unix)]
36 extern crate libc;
37 #[macro_use]
38 extern crate cfg_if;
39
40 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
41 #[allow(unused_extern_crates)]
42 extern crate rustc_cratesio_shim;
43
44 pub use rustc_serialize::hex::ToHex;
45
46 #[inline(never)]
47 #[cold]
48 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
49       f()
50 }
51
52 #[macro_export]
53 macro_rules! likely {
54       ($e:expr) => {
55             #[allow(unused_unsafe)]
56             {
57                   unsafe { std::intrinsics::likely($e) }
58             }
59       }
60 }
61
62 #[macro_export]
63 macro_rules! unlikely {
64     ($e:expr) => {
65             #[allow(unused_unsafe)]
66             {
67                   unsafe { std::intrinsics::unlikely($e) }
68             }
69       }
70 }
71
72 pub mod macros;
73 pub mod svh;
74 pub mod base_n;
75 pub mod bit_set;
76 pub mod box_region;
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 jobserver;
84 pub mod obligation_forest;
85 pub mod owning_ref;
86 pub mod ptr_key;
87 pub mod sip128;
88 pub mod small_c_str;
89 pub mod snapshot_map;
90 pub use ena::snapshot_vec;
91 pub mod sorted_map;
92 #[macro_use] pub mod stable_hasher;
93 pub mod sync;
94 pub mod tiny_list;
95 pub mod thin_vec;
96 pub mod transitive_relation;
97 pub use ena::unify;
98 pub mod vec_linked_list;
99 pub mod work_queue;
100 pub mod fingerprint;
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() {}