1 //! Various data structures used by the Rust compiler. The intention
2 //! is that code in here should be not be *specific* to rustc, so that
3 //! it can be easily unit tested and so forth.
7 //! This API is completely unstable and subject to change.
9 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
11 #![feature(in_band_lifetimes)]
12 #![feature(unboxed_closures)]
13 #![feature(generators)]
14 #![feature(generator_trait)]
15 #![feature(fn_traits)]
17 #![feature(specialization)]
18 #![feature(optin_builtin_traits)]
20 #![feature(allow_internal_unstable)]
21 #![feature(hash_raw_entry)]
22 #![feature(stmt_expr_attributes)]
23 #![feature(core_intrinsics)]
24 #![feature(integer_atomics)]
26 #![cfg_attr(unix, feature(libc))]
27 #![cfg_attr(test, feature(test))]
29 #![deny(rust_2018_idioms)]
30 #![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
34 #[allow(unused_extern_crates)]
35 extern crate serialize as rustc_serialize; // used by deriving
41 pub use rustc_serialize::hex::ToHex;
45 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
52 #[allow(unused_unsafe)]
54 unsafe { std::intrinsics::likely($e) }
60 macro_rules! unlikely {
62 #[allow(unused_unsafe)]
64 unsafe { std::intrinsics::unlikely($e) }
72 pub mod binary_search_util;
81 pub mod obligation_forest;
87 pub use ena::snapshot_vec;
89 #[macro_use] pub mod stable_hasher;
94 pub mod transitive_relation;
96 pub mod vec_linked_list;
100 pub struct OnDrop<F: Fn()>(pub F);
102 impl<F: Fn()> OnDrop<F> {
103 /// Forgets the function which prevents it from running.
104 /// Ensure that the function owns no memory, otherwise it will be leaked.
106 pub fn disable(self) {
107 std::mem::forget(self);
111 impl<F: Fn()> Drop for OnDrop<F> {
118 // See comments in src/librustc/lib.rs
120 pub fn __noop_fix_for_27438() {}