rust/compiler/rustc_data_structures/src/lib.rs

136 lines
2.9 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.
2020-09-23 19:51:56 +00:00
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(array_windows)]
2021-06-21 21:30:16 +00:00
#![feature(associated_type_bounds)]
#![feature(auto_traits)]
#![feature(bool_to_option)]
2020-09-04 07:59:41 +00:00
#![feature(control_flow_enum)]
2021-06-21 21:30:16 +00:00
#![feature(core_intrinsics)]
#![feature(extend_one)]
2022-02-18 23:48:49 +00:00
#![feature(let_else)]
2021-06-21 21:30:16 +00:00
#![feature(hash_raw_entry)]
#![feature(maybe_uninit_uninit_array)]
#![feature(min_specialization)]
#![feature(never_type)]
2021-09-08 17:13:47 +00:00
#![feature(type_alias_impl_trait)]
2021-06-21 21:30:16 +00:00
#![feature(new_uninit)]
#![feature(once_cell)]
#![feature(rustc_attrs)]
#![feature(test)]
#![feature(thread_id_value)]
2021-12-01 17:57:09 +00:00
#![feature(vec_into_raw_parts)]
2019-08-11 16:55:14 +00:00
#![allow(rustc::default_hash_types)]
#![deny(unaligned_references)]
2022-01-05 12:02:16 +00:00
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
2019-02-08 16:36:22 +00:00
#[macro_use]
2020-08-05 11:35:53 +00:00
extern crate tracing;
#[macro_use]
extern crate cfg_if;
#[macro_use]
extern crate rustc_macros;
pub use rustc_index::static_assert_size;
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) => {
match $e {
#[allow(unused_unsafe)]
e => unsafe { std::intrinsics::likely(e) },
2019-12-22 22:42:04 +00:00
}
};
2018-12-04 15:26:34 +00:00
}
#[macro_export]
macro_rules! unlikely {
($e:expr) => {
match $e {
#[allow(unused_unsafe)]
e => unsafe { std::intrinsics::unlikely(e) },
2019-12-22 22:42:04 +00:00
}
};
2018-12-04 15:26:34 +00:00
}
pub mod base_n;
pub mod binary_search_util;
pub mod captures;
pub mod flock;
2020-10-24 00:21:18 +00:00
pub mod functor;
pub mod fx;
pub mod graph;
pub mod intern;
pub mod jobserver;
2019-12-22 22:42:04 +00:00
pub mod macros;
pub mod map_in_place;
pub mod obligation_forest;
pub mod owning_ref;
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 memmap;
pub mod sorted_map;
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;
pub mod stack;
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;
2019-12-22 22:42:04 +00:00
pub mod vec_linked_list;
2021-06-04 13:05:27 +00:00
pub mod vec_map;
2019-12-22 22:42:04 +00:00
pub mod work_queue;
pub use atomic_ref::AtomicRef;
2020-03-13 18:28:25 +00:00
pub mod frozen;
pub mod sso;
2020-11-14 00:29:30 +00:00
pub mod steal;
pub mod tagged_ptr;
pub mod temp_dir;
pub mod unhash;
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
#[doc(hidden)]
pub fn __noop_fix_for_27438() {}