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.
|
|
|
|
|
2019-02-05 13:37:15 +00:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2015-04-07 10:10:53 +00:00
|
|
|
|
2018-08-12 17:07:14 +00:00
|
|
|
#![feature(in_band_lifetimes)]
|
2016-05-07 21:52:45 +00:00
|
|
|
#![feature(unboxed_closures)]
|
|
|
|
#![feature(fn_traits)]
|
2016-10-25 00:22:59 +00:00
|
|
|
#![feature(unsize)]
|
2017-03-30 13:27:27 +00:00
|
|
|
#![feature(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)]
|
2018-12-05 15:51:58 +00:00
|
|
|
#![feature(integer_atomics)]
|
2015-08-18 21:56:55 +00:00
|
|
|
|
2016-08-22 17:01:46 +00:00
|
|
|
#![cfg_attr(unix, feature(libc))]
|
2015-04-08 22:53:56 +00:00
|
|
|
#![cfg_attr(test, feature(test))]
|
2015-04-07 10:10:53 +00:00
|
|
|
|
2019-02-08 16:36:22 +00:00
|
|
|
#![deny(rust_2018_idioms)]
|
|
|
|
|
2016-03-05 13:40:33 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2019-02-08 16:36:22 +00:00
|
|
|
#[allow(unused_extern_crates)]
|
2015-04-07 10:10:53 +00:00
|
|
|
extern crate serialize as rustc_serialize; // used by deriving
|
2016-08-12 22:22:02 +00:00
|
|
|
#[cfg(unix)]
|
|
|
|
extern crate libc;
|
2017-12-03 12:49:01 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate cfg_if;
|
2015-04-07 10:11:49 +00:00
|
|
|
|
2018-04-25 16:30:39 +00:00
|
|
|
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
|
|
|
#[allow(unused_extern_crates)]
|
|
|
|
extern crate rustc_cratesio_shim;
|
|
|
|
|
2016-12-13 23:45:03 +00:00
|
|
|
pub use rustc_serialize::hex::ToHex;
|
|
|
|
|
2018-12-04 15:26:34 +00: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-08 22:57:02 +00:00
|
|
|
pub mod macros;
|
2018-08-03 18:22:22 +00:00
|
|
|
pub mod svh;
|
2016-11-04 21:37:42 +00:00
|
|
|
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 05:07:25 +00:00
|
|
|
pub mod bit_set;
|
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;
|
2016-06-07 14:28:36 +00:00
|
|
|
pub mod indexed_vec;
|
2018-05-17 03:19:08 +00:00
|
|
|
pub mod interner;
|
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;
|
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;
|
2018-08-04 00:34:23 +00:00
|
|
|
#[macro_use] pub mod stable_hasher;
|
2017-12-03 12:49:01 +00:00
|
|
|
pub mod sync;
|
2018-05-28 15:43:53 +00:00
|
|
|
pub mod tiny_list;
|
2018-08-05 10:04:56 +00:00
|
|
|
pub mod thin_vec;
|
2018-07-18 18:53:54 +00:00
|
|
|
pub mod transitive_relation;
|
|
|
|
pub use ena::unify;
|
2018-08-12 17:07:14 +00:00
|
|
|
pub mod vec_linked_list;
|
2018-06-29 10:38:48 +00:00
|
|
|
pub mod work_queue;
|
2018-08-04 00:34:23 +00:00
|
|
|
pub mod fingerprint;
|
2015-08-11 18:48:43 +00:00
|
|
|
|
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> {
|
|
|
|
/// Forgets the function which prevents it from running.
|
|
|
|
/// Ensure that the function owns no memory, otherwise it will be leaked.
|
2018-12-05 17:59:48 +00:00
|
|
|
#[inline]
|
2018-05-27 05:47:44 +00:00
|
|
|
pub fn disable(self) {
|
|
|
|
std::mem::forget(self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-15 09:38:12 +00:00
|
|
|
impl<F: Fn()> Drop for OnDrop<F> {
|
2018-12-05 17:59:48 +00:00
|
|
|
#[inline]
|
2018-03-15 09:38:12 +00:00
|
|
|
fn drop(&mut self) {
|
|
|
|
(self.0)();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-11 18:48:43 +00:00
|
|
|
// See comments in src/librustc/lib.rs
|
|
|
|
#[doc(hidden)]
|
|
|
|
pub fn __noop_fix_for_27438() {}
|