2015-04-07 10:10:53 +00: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 19:51:56 +00:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
2020-08-15 23:12:27 +00:00
|
|
|
#![allow(incomplete_features)]
|
2020-09-17 07:28:14 +00:00
|
|
|
#![feature(array_windows)]
|
2020-09-04 07:59:41 +00:00
|
|
|
#![feature(control_flow_enum)]
|
2018-08-12 17:07:14 +00:00
|
|
|
#![feature(in_band_lifetimes)]
|
2016-05-07 21:52:45 +00:00
|
|
|
#![feature(unboxed_closures)]
|
2018-12-08 19:30:23 +00:00
|
|
|
#![feature(generator_trait)]
|
2016-05-07 21:52:45 +00:00
|
|
|
#![feature(fn_traits)]
|
2020-09-08 19:39:13 +00:00
|
|
|
#![feature(int_bits_const)]
|
2020-05-09 11:59:21 +00:00
|
|
|
#![feature(min_specialization)]
|
2017-12-03 12:49:01 +00:00
|
|
|
#![feature(optin_builtin_traits)]
|
2018-09-26 21:26:46 +00:00
|
|
|
#![feature(nll)]
|
2017-12-03 12:49:01 +00:00
|
|
|
#![feature(allow_internal_unstable)]
|
2018-05-17 03:19:08 +00:00
|
|
|
#![feature(hash_raw_entry)]
|
2018-12-04 15:26:34 +00:00
|
|
|
#![feature(stmt_expr_attributes)]
|
|
|
|
#![feature(core_intrinsics)]
|
2019-07-27 12:06:49 +00:00
|
|
|
#![feature(test)]
|
2019-07-31 19:00:35 +00:00
|
|
|
#![feature(associated_type_bounds)]
|
2020-01-25 02:24:24 +00:00
|
|
|
#![feature(thread_id_value)]
|
2020-05-13 03:09:55 +00:00
|
|
|
#![feature(extend_one)]
|
2020-08-15 23:12:27 +00:00
|
|
|
#![feature(const_panic)]
|
2020-09-17 05:08:34 +00:00
|
|
|
#![feature(min_const_generics)]
|
2020-08-29 18:16:49 +00:00
|
|
|
#![feature(once_cell)]
|
2019-08-11 16:55:14 +00:00
|
|
|
#![allow(rustc::default_hash_types)]
|
2019-02-08 16:36:22 +00:00
|
|
|
|
2016-03-05 13:40:33 +00:00
|
|
|
#[macro_use]
|
2020-08-05 11:35:53 +00:00
|
|
|
extern crate tracing;
|
2017-12-03 12:49:01 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate cfg_if;
|
2020-06-11 14:49:57 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate rustc_macros;
|
2015-04-07 10:11:49 +00:00
|
|
|
|
2019-01-24 19:05:19 +00:00
|
|
|
#[inline(never)]
|
|
|
|
#[cold]
|
|
|
|
pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
|
2019-12-22 22:42:04 +00:00
|
|
|
f()
|
2019-01-24 19:05:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-04 15:26:34 +00:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! likely {
|
2019-12-22 22:42:04 +00:00
|
|
|
($e:expr) => {
|
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
{
|
|
|
|
unsafe { std::intrinsics::likely($e) }
|
|
|
|
}
|
|
|
|
};
|
2018-12-04 15:26:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! unlikely {
|
|
|
|
($e:expr) => {
|
2019-12-22 22:42:04 +00:00
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
{
|
|
|
|
unsafe { std::intrinsics::unlikely($e) }
|
|
|
|
}
|
|
|
|
};
|
2018-12-04 15:26:34 +00:00
|
|
|
}
|
|
|
|
|
2016-11-04 21:37:42 +00:00
|
|
|
pub mod base_n;
|
2019-06-17 11:55:54 +00:00
|
|
|
pub mod binary_search_util;
|
2018-12-08 19:30:23 +00:00
|
|
|
pub mod box_region;
|
2020-01-06 06:03:46 +00:00
|
|
|
pub mod captures;
|
2018-08-07 14:03:57 +00:00
|
|
|
pub mod const_cstr;
|
2018-07-18 18:53:54 +00:00
|
|
|
pub mod flock;
|
|
|
|
pub mod fx;
|
|
|
|
pub mod graph;
|
2018-12-18 08:03:38 +00:00
|
|
|
pub mod jobserver;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub mod macros;
|
2020-04-18 04:01:54 +00:00
|
|
|
pub mod map_in_place;
|
2015-11-18 19:44:24 +00:00
|
|
|
pub mod obligation_forest;
|
2018-07-18 18:53:54 +00:00
|
|
|
pub mod owning_ref;
|
|
|
|
pub mod ptr_key;
|
2017-10-16 11:16:04 +00:00
|
|
|
pub mod sip128;
|
2018-08-07 14:04:34 +00:00
|
|
|
pub mod small_c_str;
|
2016-05-21 12:18:09 +00:00
|
|
|
pub mod snapshot_map;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub mod stable_map;
|
|
|
|
pub mod svh;
|
2017-07-16 11:07:51 +00:00
|
|
|
pub use ena::snapshot_vec;
|
2018-07-18 18:53:54 +00:00
|
|
|
pub mod sorted_map;
|
2019-09-03 10:12:54 +00:00
|
|
|
pub mod stable_set;
|
2019-12-22 22:42:04 +00:00
|
|
|
#[macro_use]
|
|
|
|
pub mod stable_hasher;
|
2020-09-19 15:27:13 +00:00
|
|
|
mod atomic_ref;
|
|
|
|
pub mod fingerprint;
|
|
|
|
pub mod profiling;
|
2019-06-12 12:39:12 +00:00
|
|
|
pub mod sharded;
|
2020-03-14 18:13:55 +00:00
|
|
|
pub mod stack;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub mod sync;
|
2018-08-05 10:04:56 +00:00
|
|
|
pub mod thin_vec;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub mod tiny_list;
|
2018-07-18 18:53:54 +00:00
|
|
|
pub mod transitive_relation;
|
2019-12-22 22:42:04 +00:00
|
|
|
pub mod vec_linked_list;
|
|
|
|
pub mod work_queue;
|
2019-12-25 18:38:57 +00:00
|
|
|
pub use atomic_ref::AtomicRef;
|
2020-03-13 18:28:25 +00:00
|
|
|
pub mod frozen;
|
2020-09-19 15:27:13 +00:00
|
|
|
pub mod mini_map;
|
2020-09-23 06:09:16 +00:00
|
|
|
pub mod mini_set;
|
2020-08-15 23:12:27 +00:00
|
|
|
pub mod tagged_ptr;
|
2020-08-09 01:05:50 +00:00
|
|
|
pub mod temp_dir;
|
2020-09-02 01:27:02 +00:00
|
|
|
pub mod unhash;
|
2015-08-11 18:48:43 +00:00
|
|
|
|
2020-09-19 15:27:13 +00:00
|
|
|
pub use ena::undo_log;
|
|
|
|
pub use ena::unify;
|
|
|
|
|
2018-03-15 09:38:12 +00:00
|
|
|
pub struct OnDrop<F: Fn()>(pub F);
|
|
|
|
|
2018-05-27 05:47:44 +00:00
|
|
|
impl<F: Fn()> OnDrop<F> {
|
2019-12-22 22:42:04 +00: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 05:47:44 +00:00
|
|
|
}
|
|
|
|
|
2018-03-15 09:38:12 +00:00
|
|
|
impl<F: Fn()> Drop for OnDrop<F> {
|
2019-12-22 22:42:04 +00:00
|
|
|
#[inline]
|
|
|
|
fn drop(&mut self) {
|
|
|
|
(self.0)();
|
|
|
|
}
|
2018-03-15 09:38:12 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 13:24:45 +00:00
|
|
|
// See comments in src/librustc_middle/lib.rs
|
2015-08-11 18:48:43 +00:00
|
|
|
#[doc(hidden)]
|
|
|
|
pub fn __noop_fix_for_27438() {}
|