]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_data_structures/src/lib.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_data_structures / src / lib.rs
CommitLineData
d9579d0f
AL
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
1b1a35ee
XL
9#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
10#![feature(array_windows)]
136023e0
XL
11#![feature(associated_type_bounds)]
12#![feature(auto_traits)]
13#![feature(bool_to_option)]
1b1a35ee 14#![feature(control_flow_enum)]
136023e0
XL
15#![feature(core_intrinsics)]
16#![feature(extend_one)]
5e7ed085 17#![feature(let_else)]
136023e0 18#![feature(hash_raw_entry)]
136023e0 19#![feature(maybe_uninit_uninit_array)]
f9f354fc 20#![feature(min_specialization)]
c295e0f8
XL
21#![feature(never_type)]
22#![feature(type_alias_impl_trait)]
136023e0 23#![feature(new_uninit)]
136023e0 24#![feature(once_cell)]
5099ac24 25#![feature(rustc_attrs)]
416331ca 26#![feature(test)]
dfeec247 27#![feature(thread_id_value)]
a2a8927a 28#![feature(vec_into_raw_parts)]
e1599b0c 29#![allow(rustc::default_hash_types)]
fc512014 30#![deny(unaligned_references)]
5e7ed085 31#![allow(rustc::potential_query_instability)]
9fa01778 32
54a0048b 33#[macro_use]
3dfed10e 34extern crate tracing;
ff7c6d11
XL
35#[macro_use]
36extern crate cfg_if;
3dfed10e
XL
37#[macro_use]
38extern crate rustc_macros;
d9579d0f 39
5e7ed085
FG
40pub use rustc_index::static_assert_size;
41
9fa01778
XL
42#[inline(never)]
43#[cold]
44pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
dfeec247 45 f()
9fa01778
XL
46}
47
0731742a
XL
48#[macro_export]
49macro_rules! likely {
dfeec247 50 ($e:expr) => {
fc512014
XL
51 match $e {
52 #[allow(unused_unsafe)]
53 e => unsafe { std::intrinsics::likely(e) },
dfeec247
XL
54 }
55 };
0731742a
XL
56}
57
58#[macro_export]
59macro_rules! unlikely {
60 ($e:expr) => {
fc512014
XL
61 match $e {
62 #[allow(unused_unsafe)]
63 e => unsafe { std::intrinsics::unlikely(e) },
dfeec247
XL
64 }
65 };
0731742a
XL
66}
67
476ff2be 68pub mod base_n;
dc9dc135 69pub mod binary_search_util;
dfeec247 70pub mod captures;
8faf50e0 71pub mod flock;
fc512014 72pub mod functor;
8faf50e0 73pub mod fx;
e9174d1e 74pub mod graph;
5099ac24 75pub mod intern;
532ac7d7 76pub mod jobserver;
dfeec247 77pub mod macros;
ba9703b0 78pub mod map_in_place;
7453a54e 79pub mod obligation_forest;
8faf50e0 80pub mod owning_ref;
abe05a73 81pub mod sip128;
b7449926 82pub mod small_c_str;
5e7ed085 83pub mod small_str;
3157f602 84pub mod snapshot_map;
dfeec247
XL
85pub mod stable_map;
86pub mod svh;
0531ce1d 87pub use ena::snapshot_vec;
cdc7bbd5 88pub mod memmap;
8faf50e0 89pub mod sorted_map;
e74abb32 90pub mod stable_set;
dfeec247
XL
91#[macro_use]
92pub mod stable_hasher;
6c58768f
XL
93mod atomic_ref;
94pub mod fingerprint;
95pub mod profiling;
416331ca 96pub mod sharded;
f9f354fc 97pub mod stack;
dfeec247 98pub mod sync;
b7449926 99pub mod thin_vec;
dfeec247 100pub mod tiny_list;
8faf50e0 101pub mod transitive_relation;
dfeec247 102pub mod vec_linked_list;
17df50a5 103pub mod vec_map;
dfeec247
XL
104pub mod work_queue;
105pub use atomic_ref::AtomicRef;
ba9703b0 106pub mod frozen;
29967ef6 107pub mod sso;
fc512014 108pub mod steal;
3dfed10e
XL
109pub mod tagged_ptr;
110pub mod temp_dir;
1b1a35ee 111pub mod unhash;
e9174d1e 112
6c58768f
XL
113pub use ena::undo_log;
114pub use ena::unify;
115
0531ce1d
XL
116pub struct OnDrop<F: Fn()>(pub F);
117
94b46f34 118impl<F: Fn()> OnDrop<F> {
dfeec247
XL
119 /// Forgets the function which prevents it from running.
120 /// Ensure that the function owns no memory, otherwise it will be leaked.
121 #[inline]
122 pub fn disable(self) {
123 std::mem::forget(self);
124 }
94b46f34
XL
125}
126
0531ce1d 127impl<F: Fn()> Drop for OnDrop<F> {
dfeec247
XL
128 #[inline]
129 fn drop(&mut self) {
130 (self.0)();
131 }
0531ce1d
XL
132}
133
ba9703b0 134// See comments in src/librustc_middle/lib.rs
e9174d1e
SL
135#[doc(hidden)]
136pub fn __noop_fix_for_27438() {}