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/nightly-rustc/")]
10 #![feature(allow_internal_unstable)]
11 #![feature(array_windows)]
12 #![feature(associated_type_bounds)]
13 #![feature(auto_traits)]
14 #![feature(bool_to_option)]
15 #![feature(const_panic)]
16 #![feature(control_flow_enum)]
17 #![feature(core_intrinsics)]
18 #![feature(extend_one)]
19 #![feature(hash_raw_entry)]
20 #![feature(in_band_lifetimes)]
21 #![feature(iter_map_while)]
22 #![feature(maybe_uninit_uninit_array)]
23 #![feature(min_specialization)]
24 #![cfg_attr(bootstrap, feature(min_type_alias_impl_trait))]
25 #![cfg_attr(not(bootstrap), feature(type_alias_impl_trait))]
26 #![feature(new_uninit)]
28 #![feature(once_cell)]
30 #![feature(thread_id_value)]
31 #![allow(rustc::default_hash_types)]
32 #![deny(unaligned_references)]
39 extern crate rustc_macros;
43 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
51 #[allow(unused_unsafe)]
52 e => unsafe { std::intrinsics::likely(e) },
58 macro_rules! unlikely {
61 #[allow(unused_unsafe)]
62 e => unsafe { std::intrinsics::unlikely(e) },
68 pub mod binary_search_util;
77 pub mod obligation_forest;
85 pub use ena::snapshot_vec;
90 pub mod stable_hasher;
99 pub mod transitive_relation;
100 pub mod vec_linked_list;
103 pub use atomic_ref::AtomicRef;
111 pub use ena::undo_log;
114 pub struct OnDrop<F: Fn()>(pub F);
116 impl<F: Fn()> OnDrop<F> {
117 /// Forgets the function which prevents it from running.
118 /// Ensure that the function owns no memory, otherwise it will be leaked.
120 pub fn disable(self) {
121 std::mem::forget(self);
125 impl<F: Fn()> Drop for OnDrop<F> {
132 // See comments in src/librustc_middle/lib.rs
134 pub fn __noop_fix_for_27438() {}