]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_data_structures/src/lib.rs
New upstream version 1.71.1+dfsg1
[rustc.git] / compiler / rustc_data_structures / src / lib.rs
CommitLineData
d9579d0f 1//! Various data structures used by the Rust compiler. The intention
353b0b11 2//! is that code in here should not be *specific* to rustc, so that
d9579d0f
AL
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)]
064997fb 13#![feature(cell_leak)]
9ffffee4 14#![feature(core_intrinsics)]
136023e0
XL
15#![feature(extend_one)]
16#![feature(hash_raw_entry)]
04454e1e 17#![feature(hasher_prefixfree_extras)]
136023e0 18#![feature(maybe_uninit_uninit_array)]
f9f354fc 19#![feature(min_specialization)]
c295e0f8
XL
20#![feature(never_type)]
21#![feature(type_alias_impl_trait)]
136023e0 22#![feature(new_uninit)]
353b0b11 23#![feature(lazy_cell)]
5099ac24 24#![feature(rustc_attrs)]
2b03887a 25#![feature(negative_impls)]
416331ca 26#![feature(test)]
dfeec247 27#![feature(thread_id_value)]
a2a8927a 28#![feature(vec_into_raw_parts)]
49aad941 29#![feature(allocator_api)]
9ffffee4 30#![feature(get_mut_unchecked)]
353b0b11
FG
31#![feature(lint_reasons)]
32#![feature(unwrap_infallible)]
49aad941
FG
33#![feature(strict_provenance)]
34#![feature(ptr_alignment_type)]
35#![feature(macro_metavar_expr)]
e1599b0c 36#![allow(rustc::default_hash_types)]
5e7ed085 37#![allow(rustc::potential_query_instability)]
f2b60f7d
FG
38#![deny(rustc::untranslatable_diagnostic)]
39#![deny(rustc::diagnostic_outside_of_impl)]
49aad941 40#![deny(unsafe_op_in_unsafe_fn)]
9fa01778 41
54a0048b 42#[macro_use]
3dfed10e 43extern crate tracing;
ff7c6d11
XL
44#[macro_use]
45extern crate cfg_if;
3dfed10e
XL
46#[macro_use]
47extern crate rustc_macros;
d9579d0f 48
5e7ed085
FG
49pub use rustc_index::static_assert_size;
50
9fa01778
XL
51#[inline(never)]
52#[cold]
53pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
dfeec247 54 f()
9fa01778
XL
55}
56
476ff2be 57pub mod base_n;
dc9dc135 58pub mod binary_search_util;
dfeec247 59pub mod captures;
353b0b11 60pub mod flat_map_in_place;
8faf50e0 61pub mod flock;
fc512014 62pub mod functor;
8faf50e0 63pub mod fx;
e9174d1e 64pub mod graph;
5099ac24 65pub mod intern;
532ac7d7 66pub mod jobserver;
dfeec247 67pub mod macros;
7453a54e 68pub mod obligation_forest;
abe05a73 69pub mod sip128;
b7449926 70pub mod small_c_str;
5e7ed085 71pub mod small_str;
3157f602 72pub mod snapshot_map;
dfeec247 73pub mod svh;
0531ce1d 74pub use ena::snapshot_vec;
cdc7bbd5 75pub mod memmap;
8faf50e0 76pub mod sorted_map;
dfeec247
XL
77#[macro_use]
78pub mod stable_hasher;
6c58768f
XL
79mod atomic_ref;
80pub mod fingerprint;
49aad941 81pub mod marker;
6c58768f 82pub mod profiling;
416331ca 83pub mod sharded;
f9f354fc 84pub mod stack;
dfeec247 85pub mod sync;
dfeec247 86pub mod tiny_list;
8faf50e0 87pub mod transitive_relation;
dfeec247
XL
88pub mod vec_linked_list;
89pub mod work_queue;
90pub use atomic_ref::AtomicRef;
49aad941 91pub mod aligned;
ba9703b0 92pub mod frozen;
49aad941 93mod hashes;
353b0b11 94pub mod owned_slice;
29967ef6 95pub mod sso;
fc512014 96pub mod steal;
3dfed10e
XL
97pub mod tagged_ptr;
98pub mod temp_dir;
1b1a35ee 99pub mod unhash;
2b03887a 100pub mod unord;
e9174d1e 101
6c58768f
XL
102pub use ena::undo_log;
103pub use ena::unify;
104
49aad941
FG
105/// Returns a structure that calls `f` when dropped.
106pub fn defer<F: FnOnce()>(f: F) -> OnDrop<F> {
107 OnDrop(Some(f))
108}
109
110pub struct OnDrop<F: FnOnce()>(Option<F>);
0531ce1d 111
49aad941
FG
112impl<F: FnOnce()> OnDrop<F> {
113 /// Disables on-drop call.
dfeec247 114 #[inline]
49aad941
FG
115 pub fn disable(mut self) {
116 self.0.take();
dfeec247 117 }
94b46f34
XL
118}
119
49aad941 120impl<F: FnOnce()> Drop for OnDrop<F> {
dfeec247
XL
121 #[inline]
122 fn drop(&mut self) {
49aad941
FG
123 if let Some(f) = self.0.take() {
124 f();
125 }
dfeec247 126 }
0531ce1d
XL
127}
128
ba9703b0 129// See comments in src/librustc_middle/lib.rs
e9174d1e
SL
130#[doc(hidden)]
131pub fn __noop_fix_for_27438() {}