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.
|
|
|
|
|
2019-02-05 14:37:15 +01:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2015-04-07 06:10:53 -04:00
|
|
|
|
2018-08-12 13:07:14 -04:00
|
|
|
#![feature(in_band_lifetimes)]
|
2016-05-08 00:52:45 +03:00
|
|
|
#![feature(unboxed_closures)]
|
2018-12-08 20:30:23 +01:00
|
|
|
#![feature(generators)]
|
|
|
|
#![feature(generator_trait)]
|
2016-05-08 00:52:45 +03:00
|
|
|
#![feature(fn_traits)]
|
2016-10-24 18:22:59 -06:00
|
|
|
#![feature(unsize)]
|
2017-03-30 15:27:27 +02:00
|
|
|
#![feature(specialization)]
|
2017-12-03 13:49:01 +01:00
|
|
|
#![feature(optin_builtin_traits)]
|
2018-09-26 14:26:46 -07:00
|
|
|
#![feature(nll)]
|
2017-12-03 13:49:01 +01:00
|
|
|
#![feature(allow_internal_unstable)]
|
2018-05-17 05:19:08 +02:00
|
|
|
#![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)]
|
2019-07-27 15:06:49 +03:00
|
|
|
#![feature(test)]
|
2019-07-31 21:00:35 +02:00
|
|
|
#![feature(associated_type_bounds)]
|
2015-08-18 17:56:55 -04:00
|
|
|
|
2016-08-22 13:01:46 -04:00
|
|
|
#![cfg_attr(unix, feature(libc))]
|
2015-04-07 06:10:53 -04:00
|
|
|
|
2019-06-24 10:43:51 +02:00
|
|
|
#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
|
2019-02-09 01:36:22 +09:00
|
|
|
|
2016-03-05 08:40:33 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2016-08-12 18:22:02 -04:00
|
|
|
#[cfg(unix)]
|
|
|
|
extern crate libc;
|
2017-12-03 13:49:01 +01:00
|
|
|
#[macro_use]
|
|
|
|
extern crate cfg_if;
|
2015-04-07 06:11:49 -04:00
|
|
|
|
2016-12-14 01:45:03 +02:00
|
|
|
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) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-09 09:57:02 +11:00
|
|
|
pub mod macros;
|
2018-08-03 12:22:22 -06:00
|
|
|
pub mod svh;
|
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;
|
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;
|
2018-12-08 20:30:23 +01:00
|
|
|
pub mod box_region;
|
2018-08-07 16:03:57 +02:00
|
|
|
pub mod const_cstr;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod flock;
|
|
|
|
pub mod fx;
|
|
|
|
pub mod graph;
|
2016-06-07 17:28:36 +03:00
|
|
|
pub mod indexed_vec;
|
2018-12-18 09:03:38 +01:00
|
|
|
pub mod jobserver;
|
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;
|
2017-07-16 07:07:51 -04:00
|
|
|
pub use ena::snapshot_vec;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod sorted_map;
|
2018-08-03 18:34:23 -06:00
|
|
|
#[macro_use] pub mod stable_hasher;
|
2017-12-03 13:49:01 +01:00
|
|
|
pub mod sync;
|
2019-06-12 14:39:12 +02:00
|
|
|
pub mod sharded;
|
2018-05-28 17:43:53 +02:00
|
|
|
pub mod tiny_list;
|
2018-08-05 12:04:56 +02:00
|
|
|
pub mod thin_vec;
|
2018-07-18 21:53:54 +03:00
|
|
|
pub mod transitive_relation;
|
|
|
|
pub use ena::unify;
|
2018-08-12 13:07:14 -04:00
|
|
|
pub mod vec_linked_list;
|
2018-06-29 06:38:48 -04:00
|
|
|
pub mod work_queue;
|
2018-08-03 18:34:23 -06:00
|
|
|
pub mod fingerprint;
|
2015-08-11 11:48:43 -07:00
|
|
|
|
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)();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-11 11:48:43 -07:00
|
|
|
// See comments in src/librustc/lib.rs
|
|
|
|
#[doc(hidden)]
|
|
|
|
pub fn __noop_fix_for_27438() {}
|