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.
7 //! This API is completely unstable and subject to change.
9 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
10 #![allow(incomplete_features)]
11 #![feature(control_flow_enum)]
12 #![feature(in_band_lifetimes)]
13 #![feature(unboxed_closures)]
14 #![feature(generators)]
15 #![feature(generator_trait)]
16 #![feature(fn_traits)]
17 #![feature(min_specialization)]
18 #![feature(optin_builtin_traits)]
20 #![feature(allow_internal_unstable)]
21 #![feature(hash_raw_entry)]
22 #![feature(stmt_expr_attributes)]
23 #![feature(core_intrinsics)]
25 #![feature(associated_type_bounds)]
26 #![feature(thread_id_value)]
27 #![feature(extend_one)]
28 #![feature(const_panic)]
29 #![feature(min_const_generics)]
30 #![feature(once_cell)]
31 #![allow(rustc::default_hash_types)]
38 extern crate rustc_macros;
42 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
49 #[allow(unused_unsafe)]
51 unsafe { std::intrinsics::likely($e) }
57 macro_rules! unlikely {
59 #[allow(unused_unsafe)]
61 unsafe { std::intrinsics::unlikely($e) }
67 pub mod binary_search_util;
77 pub mod obligation_forest;
85 pub use ena::snapshot_vec;
89 pub mod stable_hasher;
95 pub mod transitive_relation;
96 pub use ena::undo_log;
101 pub mod vec_linked_list;
103 pub use atomic_ref::AtomicRef;
109 pub struct OnDrop<F: Fn()>(pub F);
111 impl<F: Fn()> OnDrop<F> {
112 /// Forgets the function which prevents it from running.
113 /// Ensure that the function owns no memory, otherwise it will be leaked.
115 pub fn disable(self) {
116 std::mem::forget(self);
120 impl<F: Fn()> Drop for OnDrop<F> {
127 // See comments in src/librustc_middle/lib.rs
129 pub fn __noop_fix_for_27438() {}