]> git.lizzy.rs Git - rust.git/blob - src/librustc_data_structures/lib.rs
Rollup merge of #75485 - RalfJung:pin, r=nagisa
[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(min_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(test)]
23 #![feature(associated_type_bounds)]
24 #![feature(thread_id_value)]
25 #![feature(extend_one)]
26 #![allow(rustc::default_hash_types)]
27
28 #[macro_use]
29 extern crate log;
30 #[macro_use]
31 extern crate cfg_if;
32 #[macro_use]
33 extern crate rustc_macros;
34
35 #[inline(never)]
36 #[cold]
37 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
38     f()
39 }
40
41 #[macro_export]
42 macro_rules! likely {
43     ($e:expr) => {
44         #[allow(unused_unsafe)]
45         {
46             unsafe { std::intrinsics::likely($e) }
47         }
48     };
49 }
50
51 #[macro_export]
52 macro_rules! unlikely {
53     ($e:expr) => {
54         #[allow(unused_unsafe)]
55         {
56             unsafe { std::intrinsics::unlikely($e) }
57         }
58     };
59 }
60
61 pub mod base_n;
62 pub mod binary_search_util;
63 pub mod box_region;
64 pub mod captures;
65 pub mod const_cstr;
66 pub mod flock;
67 pub mod fx;
68 pub mod graph;
69 pub mod jobserver;
70 pub mod macros;
71 pub mod map_in_place;
72 pub mod obligation_forest;
73 pub mod owning_ref;
74 pub mod ptr_key;
75 pub mod sip128;
76 pub mod small_c_str;
77 pub mod snapshot_map;
78 pub mod stable_map;
79 pub mod svh;
80 pub use ena::snapshot_vec;
81 pub mod sorted_map;
82 pub mod stable_set;
83 #[macro_use]
84 pub mod stable_hasher;
85 pub mod sharded;
86 pub mod stack;
87 pub mod sync;
88 pub mod thin_vec;
89 pub mod tiny_list;
90 pub mod transitive_relation;
91 pub use ena::undo_log;
92 pub use ena::unify;
93 mod atomic_ref;
94 pub mod fingerprint;
95 pub mod profiling;
96 pub mod vec_linked_list;
97 pub mod work_queue;
98 pub use atomic_ref::AtomicRef;
99 pub mod frozen;
100 pub mod temp_dir;
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_middle/lib.rs
121 #[doc(hidden)]
122 pub fn __noop_fix_for_27438() {}