2015-04-07 06:10:53 -04:00
|
|
|
//! Various data structures used by the Rust compiler. The intention
|
|
|
|
//! is that code in here should be not be *specific* to rustc, so that
|
|
|
|
//! it can be easily unit tested and so forth.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
|
|
|
|
2020-09-23 21:51:56 +02:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
2021-06-22 06:30:16 +09:00
|
|
|
#![feature(allow_internal_unstable)]
|
2020-09-17 09:28:14 +02:00
|
|
|
#![feature(array_windows)]
|
2021-06-22 06:30:16 +09:00
|
|
|
#![feature(associated_type_bounds)]
|
|
|
|
#![feature(auto_traits)]
|
|
|
|
#![feature(bool_to_option)]
|
|
|
|
#![feature(const_panic)]
|
2020-09-04 00:59:41 -07:00
|
|
|
#![feature(control_flow_enum)]
|
2021-06-22 06:30:16 +09:00
|
|
|
#![feature(core_intrinsics)]
|
|
|
|
#![feature(extend_one)]
|
|
|
|
#![feature(hash_raw_entry)]
|
2018-08-12 13:07:14 -04:00
|
|
|
#![feature(in_band_lifetimes)]
|
2021-06-22 06:30:16 +09:00
|
|
|
#![feature(iter_map_while)]
|
|
|
|
#![feature(maybe_uninit_uninit_array)]
|
2020-05-09 13:59:21 +02:00
|
|
|
#![feature(min_specialization)]
|
2021-07-27 09:14:21 -03:00
|
|
|
#![cfg_attr(bootstrap, feature(min_type_alias_impl_trait))]
|
|
|
|
#![cfg_attr(not(bootstrap), feature(type_alias_impl_trait))]
|
2021-06-22 06:30:16 +09:00
|
|
|
#![feature(new_uninit)]
|
2018-09-26 14:26:46 -07:00
|
|
|
#![feature(nll)]
|
2021-06-22 06:30:16 +09:00
|
|
|
#![feature(once_cell)]
|
2019-07-27 15:06:49 +03:00
|
|
|
#![feature(test)]
|
2020-01-24 21:24:24 -05:00
|
|
|
#![feature(thread_id_value)]
|
2019-08-11 12:55:14 -04:00
|
|
|
#![allow(rustc::default_hash_types)]
|
2020-11-20 01:13:15 -08:00
|
|
|
#![deny(unaligned_references)]
|
2019-02-09 01:36:22 +09:00
|
|
|
|
2016-03-05 08:40:33 -05:00
|
|
|
#[macro_use]
|
2020-08-05 17:05:53 +05:30
|
|
|
extern crate tracing;
|
2017-12-03 13:49:01 +01:00
|
|
|
#[macro_use]
|
|
|
|
extern crate cfg_if;
|
2020-06-11 15:49:57 +01:00
|
|
|
#[macro_use]
|
|
|
|
extern crate rustc_macros;
|
2015-04-07 06:11:49 -04:00
|
|
|
|
2019-01-24 20:05:19 +01:00
|
|
|
#[inline(never)]
|
|
|
|
#[cold]
|
|
|
|
pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
|
2019-12-22 17:42:04 -05:00
|
|
|
f()
|
2019-01-24 20:05:19 +01:00
|
|
|
}
|
|
|
|
|
2018-12-04 16:26:34 +01:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! likely {
|
2019-12-22 17:42:04 -05:00
|
|
|
($e:expr) => {
|
2020-11-14 13:54:45 -08:00
|
|
|
match $e {
|
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
e => unsafe { std::intrinsics::likely(e) },
|
2019-12-22 17:42:04 -05:00
|
|
|
}
|
|
|
|
};
|
2018-12-04 16:26:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! unlikely {
|
|
|
|
($e:expr) => {
|
2020-11-14 13:54:45 -08:00
|
|
|
match $e {
|
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
e => unsafe { std::intrinsics::unlikely(e) },
|
2019-12-22 17:42:04 -05:00
|
|
|
}
|
|
|
|
};
|
2018-12-04 16:26:34 +01:00
|
|
|
}
|
|
|
|
|
2016-11-04 17:37:42 -04:00
|
|
|
pub mod base_n;
|
2019-06-17 07:55:54 -04:00
|
|
|
pub mod binary_search_util;
|
2020-01-06 07:03:46 +01:00
|
|
|
pub mod captures;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod flock;
|
2020-10-24 02:21:18 +02:00
|
|
|
pub mod functor;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod fx;
|
|
|
|
pub mod graph;
|
2018-12-18 09:03:38 +01:00
|
|
|
pub mod jobserver;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod macros;
|
2020-04-18 13:01:54 +09:00
|
|
|
pub mod map_in_place;
|
2015-11-18 14:44:24 -05:00
|
|
|
pub mod obligation_forest;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod owning_ref;
|
|
|
|
pub mod ptr_key;
|
2017-10-16 13:16:04 +02:00
|
|
|
pub mod sip128;
|
2018-08-07 16:04:34 +02:00
|
|
|
pub mod small_c_str;
|
2016-05-21 08:18:09 -04:00
|
|
|
pub mod snapshot_map;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod stable_map;
|
|
|
|
pub mod svh;
|
2017-07-16 07:07:51 -04:00
|
|
|
pub use ena::snapshot_vec;
|
2021-03-29 11:18:52 +02:00
|
|
|
pub mod memmap;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod sorted_map;
|
2019-09-03 15:42:54 +05:30
|
|
|
pub mod stable_set;
|
2019-12-22 17:42:04 -05:00
|
|
|
#[macro_use]
|
|
|
|
pub mod stable_hasher;
|
2020-09-19 17:27:13 +02:00
|
|
|
mod atomic_ref;
|
|
|
|
pub mod fingerprint;
|
|
|
|
pub mod profiling;
|
2019-06-12 14:39:12 +02:00
|
|
|
pub mod sharded;
|
2020-03-14 20:13:55 +02:00
|
|
|
pub mod stack;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod sync;
|
2018-08-05 12:04:56 +02:00
|
|
|
pub mod thin_vec;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod tiny_list;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod transitive_relation;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod vec_linked_list;
|
2021-06-04 10:05:27 -03:00
|
|
|
pub mod vec_map;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod work_queue;
|
2019-12-25 13:38:57 -05:00
|
|
|
pub use atomic_ref::AtomicRef;
|
2020-03-13 13:28:25 -05:00
|
|
|
pub mod frozen;
|
2020-09-23 23:32:11 -05:00
|
|
|
pub mod sso;
|
2020-11-14 01:29:30 +01:00
|
|
|
pub mod steal;
|
2020-08-15 19:12:27 -04:00
|
|
|
pub mod tagged_ptr;
|
2020-08-08 21:05:50 -04:00
|
|
|
pub mod temp_dir;
|
2020-09-01 18:27:02 -07:00
|
|
|
pub mod unhash;
|
2015-08-11 11:48:43 -07:00
|
|
|
|
2020-09-19 17:27:13 +02:00
|
|
|
pub use ena::undo_log;
|
|
|
|
pub use ena::unify;
|
|
|
|
|
2018-03-15 10:38:12 +01:00
|
|
|
pub struct OnDrop<F: Fn()>(pub F);
|
|
|
|
|
2018-05-27 07:47:44 +02:00
|
|
|
impl<F: Fn()> OnDrop<F> {
|
2019-12-22 17:42:04 -05:00
|
|
|
/// Forgets the function which prevents it from running.
|
|
|
|
/// Ensure that the function owns no memory, otherwise it will be leaked.
|
|
|
|
#[inline]
|
|
|
|
pub fn disable(self) {
|
|
|
|
std::mem::forget(self);
|
|
|
|
}
|
2018-05-27 07:47:44 +02:00
|
|
|
}
|
|
|
|
|
2018-03-15 10:38:12 +01:00
|
|
|
impl<F: Fn()> Drop for OnDrop<F> {
|
2019-12-22 17:42:04 -05:00
|
|
|
#[inline]
|
|
|
|
fn drop(&mut self) {
|
|
|
|
(self.0)();
|
|
|
|
}
|
2018-03-15 10:38:12 +01:00
|
|
|
}
|
|
|
|
|
2020-03-29 15:24:45 +02:00
|
|
|
// See comments in src/librustc_middle/lib.rs
|
2015-08-11 11:48:43 -07:00
|
|
|
#[doc(hidden)]
|
|
|
|
pub fn __noop_fix_for_27438() {}
|