rustc_data_structures/
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/nightly-rustc/")]
10#![allow(rustc::default_hash_types)]
11#![allow(rustc::potential_query_instability)]
12
13extern crate tracing;
14#[macro_use]
15extern crate cfg_if;
16
17#[inline(never)]
18#[cold]
19pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
20    f()
21}
22
23#[macro_export]
24macro_rules! likely {
25    ($e:expr) => {
26        match $e {
27            #[allow(unused_unsafe)]
28            e => unsafe { std::intrinsics::likely(e) },
29        }
30    };
31}
32
33pub mod base_n;
34
35pub mod captures;
36pub mod flock;
37pub mod fx;
38
39pub mod macros;
40pub mod stable_map;
41pub use ena::snapshot_vec;
42pub mod stable_set;
43#[macro_use]
44
45mod atomic_ref;
46pub mod sync;
47pub use atomic_ref::AtomicRef;
48pub mod frozen;
49
50pub mod temp_dir;
51pub mod unhash;
52
53pub use ena::undo_log;
54pub use ena::unify;
55
56pub struct OnDrop<F: Fn()>(pub F);
57
58impl<F: Fn()> OnDrop<F> {
59    /// Forgets the function which prevents it from running.
60    /// Ensure that the function owns no memory, otherwise it will be leaked.
61    #[inline]
62    pub fn disable(self) {
63        std::mem::forget(self);
64    }
65}
66
67impl<F: Fn()> Drop for OnDrop<F> {
68    #[inline]
69    fn drop(&mut self) {
70        (self.0)();
71    }
72}
73
74// See comments in src/librustc_middle/lib.rs
75#[doc(hidden)]
76pub fn __noop_fix_for_27438() {}