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