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(fn_traits)]
15 #![feature(specialization)]
16 #![feature(optin_builtin_traits)]
18 #![feature(allow_internal_unstable)]
19 #![feature(hash_raw_entry)]
20 #![feature(stmt_expr_attributes)]
21 #![feature(core_intrinsics)]
22 #![feature(integer_atomics)]
24 #![cfg_attr(unix, feature(libc))]
25 #![cfg_attr(test, feature(test))]
27 #![deny(rust_2018_idioms)]
31 #[allow(unused_extern_crates)]
32 extern crate serialize as rustc_serialize; // used by deriving
38 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
39 #[allow(unused_extern_crates)]
40 extern crate rustc_cratesio_shim;
42 pub use rustc_serialize::hex::ToHex;
46 pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
53 #[allow(unused_unsafe)]
55 unsafe { std::intrinsics::likely($e) }
61 macro_rules! unlikely {
63 #[allow(unused_unsafe)]
65 unsafe { std::intrinsics::unlikely($e) }
80 pub mod obligation_forest;
86 pub use ena::snapshot_vec;
88 #[macro_use] pub mod stable_hasher;
92 pub mod transitive_relation;
94 pub mod vec_linked_list;
98 pub struct OnDrop<F: Fn()>(pub F);
100 impl<F: Fn()> OnDrop<F> {
101 /// Forgets the function which prevents it from running.
102 /// Ensure that the function owns no memory, otherwise it will be leaked.
104 pub fn disable(self) {
105 std::mem::forget(self);
109 impl<F: Fn()> Drop for OnDrop<F> {
116 // See comments in src/librustc/lib.rs
118 pub fn __noop_fix_for_27438() {}