]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_data_structures/src/lib.rs
Rollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddle
[rust.git] / compiler / rustc_data_structures / src / 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/nightly-rustc/")]
10 #![feature(array_windows)]
11 #![feature(associated_type_bounds)]
12 #![feature(auto_traits)]
13 #![feature(bool_to_option)]
14 #![feature(control_flow_enum)]
15 #![feature(core_intrinsics)]
16 #![feature(extend_one)]
17 #![feature(hash_raw_entry)]
18 #![feature(maybe_uninit_uninit_array)]
19 #![feature(min_specialization)]
20 #![feature(never_type)]
21 #![feature(type_alias_impl_trait)]
22 #![feature(new_uninit)]
23 #![feature(once_cell)]
24 #![feature(rustc_attrs)]
25 #![feature(test)]
26 #![feature(thread_id_value)]
27 #![feature(vec_into_raw_parts)]
28 #![allow(rustc::default_hash_types)]
29 #![deny(unaligned_references)]
30 #![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
31
32 #[macro_use]
33 extern crate tracing;
34 #[macro_use]
35 extern crate cfg_if;
36 #[macro_use]
37 extern crate rustc_macros;
38
39 #[inline(never)]
40 #[cold]
41 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
42     f()
43 }
44
45 #[macro_export]
46 macro_rules! likely {
47     ($e:expr) => {
48         match $e {
49             #[allow(unused_unsafe)]
50             e => unsafe { std::intrinsics::likely(e) },
51         }
52     };
53 }
54
55 #[macro_export]
56 macro_rules! unlikely {
57     ($e:expr) => {
58         match $e {
59             #[allow(unused_unsafe)]
60             e => unsafe { std::intrinsics::unlikely(e) },
61         }
62     };
63 }
64
65 pub mod base_n;
66 pub mod binary_search_util;
67 pub mod captures;
68 pub mod flock;
69 pub mod functor;
70 pub mod fx;
71 pub mod graph;
72 pub mod intern;
73 pub mod jobserver;
74 pub mod macros;
75 pub mod map_in_place;
76 pub mod obligation_forest;
77 pub mod owning_ref;
78 pub mod sip128;
79 pub mod small_c_str;
80 pub mod snapshot_map;
81 pub mod stable_map;
82 pub mod svh;
83 pub use ena::snapshot_vec;
84 pub mod memmap;
85 pub mod sorted_map;
86 pub mod stable_set;
87 #[macro_use]
88 pub mod stable_hasher;
89 mod atomic_ref;
90 pub mod fingerprint;
91 pub mod profiling;
92 pub mod sharded;
93 pub mod stack;
94 pub mod sync;
95 pub mod thin_vec;
96 pub mod tiny_list;
97 pub mod transitive_relation;
98 pub mod vec_linked_list;
99 pub mod vec_map;
100 pub mod work_queue;
101 pub use atomic_ref::AtomicRef;
102 pub mod frozen;
103 pub mod sso;
104 pub mod steal;
105 pub mod tagged_ptr;
106 pub mod temp_dir;
107 pub mod unhash;
108
109 pub use ena::undo_log;
110 pub use ena::unify;
111
112 pub struct OnDrop<F: Fn()>(pub F);
113
114 impl<F: Fn()> OnDrop<F> {
115     /// Forgets the function which prevents it from running.
116     /// Ensure that the function owns no memory, otherwise it will be leaked.
117     #[inline]
118     pub fn disable(self) {
119         std::mem::forget(self);
120     }
121 }
122
123 impl<F: Fn()> Drop for OnDrop<F> {
124     #[inline]
125     fn drop(&mut self) {
126         (self.0)();
127     }
128 }
129
130 // See comments in src/librustc_middle/lib.rs
131 #[doc(hidden)]
132 pub fn __noop_fix_for_27438() {}