rust/src/librustc_data_structures/lib.rs

120 lines
2.5 KiB
Rust
Raw Normal View History

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.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(in_band_lifetimes)]
2016-05-07 21:52:45 +00:00
#![feature(unboxed_closures)]
#![feature(generators)]
#![feature(generator_trait)]
2016-05-07 21:52:45 +00:00
#![feature(fn_traits)]
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(nll)]
#![feature(allow_internal_unstable)]
#![feature(hash_raw_entry)]
2018-12-04 15:26:34 +00:00
#![feature(stmt_expr_attributes)]
#![feature(core_intrinsics)]
#![feature(test)]
#![feature(associated_type_bounds)]
#![feature(thread_id_value)]
2019-08-11 16:55:14 +00:00
#![allow(rustc::default_hash_types)]
2019-02-08 16:36:22 +00:00
#[macro_use]
extern crate log;
#[cfg(unix)]
extern crate libc;
#[macro_use]
extern crate cfg_if;
pub use rustc_serialize::hex::ToHex;
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
}
pub mod base_n;
pub mod binary_search_util;
pub mod box_region;
pub mod captures;
pub mod const_cstr;
pub mod flock;
pub mod fx;
pub mod graph;
pub mod jobserver;
2019-12-22 22:42:04 +00:00
pub mod macros;
pub mod obligation_forest;
pub mod owning_ref;
pub mod ptr_key;
pub mod sip128;
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;
pub use ena::snapshot_vec;
pub mod sorted_map;
pub mod stable_set;
2019-12-22 22:42:04 +00:00
#[macro_use]
pub mod stable_hasher;
2019-06-12 12:39:12 +00:00
pub mod sharded;
2019-12-22 22:42:04 +00:00
pub mod sync;
pub mod thin_vec;
2019-12-22 22:42:04 +00:00
pub mod tiny_list;
pub mod transitive_relation;
pub use ena::unify;
mod atomic_ref;
2018-08-04 00:34:23 +00:00
pub mod fingerprint;
pub mod profiling;
2019-12-22 22:42:04 +00:00
pub mod vec_linked_list;
pub mod work_queue;
pub use atomic_ref::AtomicRef;
2020-03-13 18:28:25 +00:00
pub mod frozen;
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
}
// See comments in src/librustc/lib.rs
#[doc(hidden)]
pub fn __noop_fix_for_27438() {}