• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Various data structures used by the Rust compiler. The intention
2 //! is that code in here should 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(cell_leak)]
14 #![feature(core_intrinsics)]
15 #![feature(extend_one)]
16 #![feature(hash_raw_entry)]
17 #![feature(hasher_prefixfree_extras)]
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(lazy_cell)]
24 #![feature(rustc_attrs)]
25 #![feature(negative_impls)]
26 #![feature(test)]
27 #![feature(thread_id_value)]
28 #![feature(vec_into_raw_parts)]
29 #![feature(allocator_api)]
30 #![feature(get_mut_unchecked)]
31 #![feature(lint_reasons)]
32 #![feature(unwrap_infallible)]
33 #![feature(strict_provenance)]
34 #![feature(ptr_alignment_type)]
35 #![feature(macro_metavar_expr)]
36 #![allow(rustc::default_hash_types)]
37 #![allow(rustc::potential_query_instability)]
38 #![deny(rustc::untranslatable_diagnostic)]
39 #![deny(rustc::diagnostic_outside_of_impl)]
40 #![deny(unsafe_op_in_unsafe_fn)]
41 
42 #[macro_use]
43 extern crate tracing;
44 #[macro_use]
45 extern crate cfg_if;
46 #[macro_use]
47 extern crate rustc_macros;
48 
49 pub use rustc_index::static_assert_size;
50 
51 #[inline(never)]
52 #[cold]
cold_path<F: FnOnce() -> R, R>(f: F) -> R53 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
54     f()
55 }
56 
57 pub mod base_n;
58 pub mod binary_search_util;
59 pub mod captures;
60 pub mod flat_map_in_place;
61 pub mod flock;
62 pub mod functor;
63 pub mod fx;
64 pub mod graph;
65 pub mod intern;
66 pub mod jobserver;
67 pub mod macros;
68 pub mod obligation_forest;
69 pub mod sip128;
70 pub mod small_c_str;
71 pub mod snapshot_map;
72 pub mod svh;
73 pub use ena::snapshot_vec;
74 pub mod memmap;
75 pub mod sorted_map;
76 #[macro_use]
77 pub mod stable_hasher;
78 mod atomic_ref;
79 pub mod fingerprint;
80 pub mod marker;
81 pub mod profiling;
82 pub mod sharded;
83 pub mod stack;
84 pub mod sync;
85 pub mod tiny_list;
86 pub mod transitive_relation;
87 pub mod vec_linked_list;
88 pub mod work_queue;
89 pub use atomic_ref::AtomicRef;
90 pub mod aligned;
91 pub mod frozen;
92 mod hashes;
93 pub mod owned_slice;
94 pub mod sso;
95 pub mod steal;
96 pub mod tagged_ptr;
97 pub mod temp_dir;
98 pub mod unhash;
99 pub mod unord;
100 
101 pub use ena::undo_log;
102 pub use ena::unify;
103 
104 /// Returns a structure that calls `f` when dropped.
defer<F: FnOnce()>(f: F) -> OnDrop<F>105 pub fn defer<F: FnOnce()>(f: F) -> OnDrop<F> {
106     OnDrop(Some(f))
107 }
108 
109 pub struct OnDrop<F: FnOnce()>(Option<F>);
110 
111 impl<F: FnOnce()> OnDrop<F> {
112     /// Disables on-drop call.
113     #[inline]
disable(mut self)114     pub fn disable(mut self) {
115         self.0.take();
116     }
117 }
118 
119 impl<F: FnOnce()> Drop for OnDrop<F> {
120     #[inline]
drop(&mut self)121     fn drop(&mut self) {
122         if let Some(f) = self.0.take() {
123             f();
124         }
125     }
126 }
127 
128 // See comments in src/librustc_middle/lib.rs
129 #[doc(hidden)]
__noop_fix_for_27438()130 pub fn __noop_fix_for_27438() {}
131