120 lines
2.6 KiB
Rust
Raw Normal View History

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.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
2015-04-07 06:10:53 -04:00
#![feature(in_band_lifetimes)]
2016-05-08 00:52:45 +03:00
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#![feature(unsize)]
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(nll)]
#![feature(allow_internal_unstable)]
#![feature(hash_raw_entry)]
2018-12-04 16:26:34 +01:00
#![feature(stmt_expr_attributes)]
#![feature(core_intrinsics)]
2018-12-05 16:51:58 +01:00
#![feature(integer_atomics)]
#![cfg_attr(unix, feature(libc))]
2015-04-08 18:53:56 -04:00
#![cfg_attr(test, feature(test))]
2015-04-07 06:10:53 -04:00
2019-02-09 01:36:22 +09:00
#![deny(rust_2018_idioms)]
#[macro_use]
extern crate log;
2019-02-09 01:36:22 +09:00
#[allow(unused_extern_crates)]
2015-04-07 06:10:53 -04:00
extern crate serialize as rustc_serialize; // used by deriving
#[cfg(unix)]
extern crate libc;
#[macro_use]
extern crate cfg_if;
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
#[allow(unused_extern_crates)]
extern crate rustc_cratesio_shim;
pub use rustc_serialize::hex::ToHex;
2019-01-24 20:05:19 +01:00
#[inline(never)]
#[cold]
pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
f()
}
2018-12-04 16:26:34 +01:00
#[macro_export]
macro_rules! likely {
($e:expr) => {
#[allow(unused_unsafe)]
{
unsafe { std::intrinsics::likely($e) }
}
}
}
#[macro_export]
macro_rules! unlikely {
($e:expr) => {
#[allow(unused_unsafe)]
{
unsafe { std::intrinsics::unlikely($e) }
}
}
}
pub mod macros;
2018-08-03 12:22:22 -06:00
pub mod svh;
pub mod base_n;
Merge indexed_set.rs into bitvec.rs, and rename it bit_set.rs. Currently we have two files implementing bitsets (and 2D bit matrices). This commit combines them into one, taking the best features from each. This involves renaming a lot of things. The high level changes are as follows. - bitvec.rs --> bit_set.rs - indexed_set.rs --> (removed) - BitArray + IdxSet --> BitSet (merged, see below) - BitVector --> GrowableBitSet - {,Sparse,Hybrid}IdxSet --> {,Sparse,Hybrid}BitSet - BitMatrix --> BitMatrix - SparseBitMatrix --> SparseBitMatrix The changes within the bitset types themselves are as follows. ``` OLD OLD NEW BitArray<C> IdxSet<T> BitSet<T> -------- ------ ------ grow - grow new - (remove) new_empty new_empty new_empty new_filled new_filled new_filled - to_hybrid to_hybrid clear clear clear set_up_to set_up_to set_up_to clear_above - clear_above count - count contains(T) contains(&T) contains(T) contains_all - superset is_empty - is_empty insert(T) add(&T) insert(T) insert_all - insert_all() remove(T) remove(&T) remove(T) words words words words_mut words_mut words_mut - overwrite overwrite merge union union - subtract subtract - intersect intersect iter iter iter ``` In general, when choosing names I went with: - names that are more obvious (e.g. `BitSet` over `IdxSet`). - names that are more like the Rust libraries (e.g. `T` over `C`, `insert` over `add`); - names that are more set-like (e.g. `union` over `merge`, `superset` over `contains_all`, `domain_size` over `num_bits`). Also, using `T` for index arguments seems more sensible than `&T` -- even though the latter is standard in Rust collection types -- because indices are always copyable. It also results in fewer `&` and `*` sigils in practice.
2018-09-14 15:07:25 +10:00
pub mod bit_set;
pub mod const_cstr;
pub mod flock;
pub mod fx;
pub mod graph;
pub mod indexed_vec;
pub mod interner;
pub mod jobserver;
pub mod obligation_forest;
pub mod owning_ref;
pub mod ptr_key;
pub mod sip128;
pub mod small_c_str;
2016-05-21 08:18:09 -04:00
pub mod snapshot_map;
pub use ena::snapshot_vec;
pub mod sorted_map;
2018-08-03 18:34:23 -06:00
#[macro_use] pub mod stable_hasher;
pub mod sync;
2018-05-28 17:43:53 +02:00
pub mod tiny_list;
pub mod thin_vec;
pub mod transitive_relation;
pub use ena::unify;
pub mod vec_linked_list;
pub mod work_queue;
2018-08-03 18:34:23 -06:00
pub mod fingerprint;
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> {
/// Forgets the function which prevents it from running.
/// Ensure that the function owns no memory, otherwise it will be leaked.
2018-12-05 18:59:48 +01:00
#[inline]
2018-05-27 07:47:44 +02:00
pub fn disable(self) {
std::mem::forget(self);
}
}
2018-03-15 10:38:12 +01:00
impl<F: Fn()> Drop for OnDrop<F> {
2018-12-05 18:59:48 +01:00
#[inline]
2018-03-15 10:38:12 +01:00
fn drop(&mut self) {
(self.0)();
}
}
// See comments in src/librustc/lib.rs
#[doc(hidden)]
pub fn __noop_fix_for_27438() {}