rustc_data_structures/
lib.rs1#![allow(internal_features)]
11#![allow(rustc::default_hash_types)]
12#![allow(rustc::potential_query_instability)]
13#![deny(unsafe_op_in_unsafe_fn)]
14#![feature(allocator_api)]
15#![feature(array_windows)]
16#![feature(ascii_char)]
17#![feature(ascii_char_variants)]
18#![feature(assert_matches)]
19#![feature(auto_traits)]
20#![feature(cfg_select)]
21#![feature(core_intrinsics)]
22#![feature(dropck_eyepatch)]
23#![feature(extend_one)]
24#![feature(file_buffered)]
25#![feature(map_try_insert)]
26#![feature(min_specialization)]
27#![feature(negative_impls)]
28#![feature(never_type)]
29#![feature(ptr_alignment_type)]
30#![feature(rustc_attrs)]
31#![feature(sized_hierarchy)]
32#![feature(test)]
33#![feature(thread_id_value)]
34#![feature(trusted_len)]
35#![feature(type_alias_impl_trait)]
36#![feature(unwrap_infallible)]
37use std::fmt;
40
41pub use atomic_ref::AtomicRef;
42pub use ena::{snapshot_vec, undo_log, unify};
43pub use rustc_index::static_assert_size;
44pub use {either, indexmap, smallvec, thin_vec};
46
47pub mod aligned;
48pub mod base_n;
49pub mod binary_search_util;
50pub mod fingerprint;
51pub mod flat_map_in_place;
52pub mod flock;
53pub mod frozen;
54pub mod fx;
55pub mod graph;
56pub mod intern;
57pub mod jobserver;
58pub mod marker;
59pub mod memmap;
60pub mod obligation_forest;
61pub mod owned_slice;
62pub mod packed;
63pub mod profiling;
64pub mod sharded;
65pub mod small_c_str;
66pub mod snapshot_map;
67pub mod sorted_map;
68pub mod sso;
69pub mod stable_hasher;
70pub mod stack;
71pub mod steal;
72pub mod svh;
73pub mod sync;
74pub mod tagged_ptr;
75pub mod temp_dir;
76pub mod thinvec;
77pub mod thousands;
78pub mod transitive_relation;
79pub mod unhash;
80pub mod union_find;
81pub mod unord;
82pub mod vec_cache;
83pub mod work_queue;
84
85mod atomic_ref;
86
87#[inline(never)]
89#[cold]
90pub fn outline<F: FnOnce() -> R, R>(f: F) -> R {
91 f()
92}
93
94pub fn defer<F: FnOnce()>(f: F) -> OnDrop<F> {
96 OnDrop(Some(f))
97}
98
99pub struct OnDrop<F: FnOnce()>(Option<F>);
100
101impl<F: FnOnce()> OnDrop<F> {
102 #[inline]
104 pub fn disable(mut self) {
105 self.0.take();
106 }
107}
108
109impl<F: FnOnce()> Drop for OnDrop<F> {
110 #[inline]
111 fn drop(&mut self) {
112 if let Some(f) = self.0.take() {
113 f();
114 }
115 }
116}
117
118pub struct FatalErrorMarker;
120
121pub fn make_display(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display {
123 struct Printer<F> {
124 f: F,
125 }
126 impl<F> fmt::Display for Printer<F>
127 where
128 F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,
129 {
130 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
131 (self.f)(fmt)
132 }
133 }
134
135 Printer { f }
136}
137
138#[doc(hidden)]
140pub fn __noop_fix_for_windows_dllimport_issue() {}
141
142#[macro_export]
143macro_rules! external_bitflags_debug {
144 ($Name:ident) => {
145 impl ::std::fmt::Debug for $Name {
146 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
147 ::bitflags::parser::to_writer(self, f)
148 }
149 }
150 };
151}