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