]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_data_structures/src/lib.rs
Replace const_generics feature gate with min_const_generics
[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/")]
10 #![allow(incomplete_features)]
11 #![feature(control_flow_enum)]
12 #![feature(in_band_lifetimes)]
13 #![feature(unboxed_closures)]
14 #![feature(generators)]
15 #![feature(generator_trait)]
16 #![feature(fn_traits)]
17 #![feature(min_specialization)]
18 #![feature(optin_builtin_traits)]
19 #![feature(nll)]
20 #![feature(allow_internal_unstable)]
21 #![feature(hash_raw_entry)]
22 #![feature(stmt_expr_attributes)]
23 #![feature(core_intrinsics)]
24 #![feature(test)]
25 #![feature(associated_type_bounds)]
26 #![feature(thread_id_value)]
27 #![feature(extend_one)]
28 #![feature(const_panic)]
29 #![feature(min_const_generics)]
30 #![feature(once_cell)]
31 #![allow(rustc::default_hash_types)]
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         #[allow(unused_unsafe)]
50         {
51             unsafe { std::intrinsics::likely($e) }
52         }
53     };
54 }
55
56 #[macro_export]
57 macro_rules! unlikely {
58     ($e:expr) => {
59         #[allow(unused_unsafe)]
60         {
61             unsafe { std::intrinsics::unlikely($e) }
62         }
63     };
64 }
65
66 pub mod base_n;
67 pub mod binary_search_util;
68 pub mod box_region;
69 pub mod captures;
70 pub mod const_cstr;
71 pub mod flock;
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 sorted_map;
87 pub mod stable_set;
88 #[macro_use]
89 pub mod stable_hasher;
90 pub mod sharded;
91 pub mod stack;
92 pub mod sync;
93 pub mod thin_vec;
94 pub mod tiny_list;
95 pub mod transitive_relation;
96 pub use ena::undo_log;
97 pub use ena::unify;
98 mod atomic_ref;
99 pub mod fingerprint;
100 pub mod profiling;
101 pub mod vec_linked_list;
102 pub mod work_queue;
103 pub use atomic_ref::AtomicRef;
104 pub mod frozen;
105 pub mod tagged_ptr;
106 pub mod temp_dir;
107 pub mod unhash;
108
109 pub struct OnDrop<F: Fn()>(pub F);
110
111 impl<F: Fn()> OnDrop<F> {
112     /// Forgets the function which prevents it from running.
113     /// Ensure that the function owns no memory, otherwise it will be leaked.
114     #[inline]
115     pub fn disable(self) {
116         std::mem::forget(self);
117     }
118 }
119
120 impl<F: Fn()> Drop for OnDrop<F> {
121     #[inline]
122     fn drop(&mut self) {
123         (self.0)();
124     }
125 }
126
127 // See comments in src/librustc_middle/lib.rs
128 #[doc(hidden)]
129 pub fn __noop_fix_for_27438() {}