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